Reputation: 1773
I am hitting a roadblock in my thespian implementation. I have an infinite while loop that will break if a condition is met, but I want to stay in the while loop until the condition is met. I understand that it is blocking and I am fine with not being able to receive any messages while in the infinite loop, however, it seems like other actors are not entering the loop until the previous actor has exited their infinite loop. This makes me believe that all actors are on a single thread. Any idea on workarounds?
class Actor(ActorTypeDispatcher):
def logic(self):
should_break = False
while True:
print(self.id)
if should_break:
break
**insert logic to determine if should_break is True or False**
I have instantiated 100 actors (the id is incremented from 1-100). Actors 1-5 immediately enter the break statement after an iteration, however when I print the id it is stuck on 6. The logic to break the loop for Actor where id = 6 is dependent on other Actors actions simultaneously.
Upvotes: 1
Views: 217
Reputation: 20611
Per Thespian's docs:
By default, the "simpleSystemBase" is used, which runs all Actors synchronously in the current process. While this base is very useful for debugging (see the Debugging section), it does not provide the level of concurrency usually desired at production time.
Which suggests that by default Thespian effectively runs all actors in the same thread.
Alternative bases (e.g. the multiprocTCPBase
, which the docs elsewhere cite as the base to choose unless you're sure you want multiprocUDPBase
or multiprocQueueBase
) can be passed to the ActorSystem
at startup. The default simpleSystemBase
has no parallelism.
Upvotes: 2