question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass max_count to troupe decorator dynamically

See original GitHub issue

I am struggling to be able to pass a max_count value to the troupe decorator dynamically. I am calling like this:

from thespian.troupe import troupe
from thespain.actors import *

count = 30
decorated_actor= troupe(max_count=count)(Actor)

But when I pass the decorated_actor to the actor system it behaves as if its not decorated. What am I doing wrong here?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kquickcommented, Aug 17, 2018

The limit is mostly that imposed by your OS, not Thespian. There are various OS limits like the number of processes, number of open file descriptors, etc. that will probably be what you will encounter. I do not think 50 is likely to be an issue.

In addition, the troupe decorator will only create actors on-demand: if all existing actors are handling work and a new work message arrives, a new actor will be created (subject to the limit), but if there is an idle actor the work will be given to that actor instead. There is also an idle limit count for the troupe decorator, so if you do something like:

@troupe(max_count=50, idle_count=3)
class MyActor(Actor): ...

Then normally there will only be 4 MyActor instances running (the leader plus the 3 workers) but it will create up to 50 workers as needed.

0reactions
andattcommented, Mar 12, 2020

Hi @kquick

Yes I am still using Thespian. That’s brilliant news! Thanks Kevin. Will be very handy to be able to do that. Will take a look at the latest update and give it a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure a decorator in Python - Stack Overflow
Time passes c = input("Max count: ") Calculation = troupe(max_count=int(c), idle_count=2)(Calculation). (or, simply wait until you do have c ...
Read more >
How to Dynamically Add Behaviors With Decorator Pattern
The Decorator Pattern is a structural design pattern that allows you to dynamically add behavior to a class without making changes to that ......
Read more >
Primer on Python Decorators
In this introductory tutorial, we'll look at what Python decorators are and how to create and use them.
Read more >
Dynamic Row Level Security with Manager Level Access in ...
I have written while ago, about how to implement a dynamic row level security in Power BI. This post is an addition to...
Read more >
SQL Query with dynamic number of columns - Ask TOM
SQL Query with dynamic number of columns Hi Tom,I have a table like thiscreate table temp1(f_name ... 16 l_query := l_query || '...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found