每个戏剧演员都在一个线程上运行吗?
我在thespian实施中遇到了障碍。我有一个无限的循环,如果满足条件,它将破裂,但我想保持在段环上,直到满足条件。我知道它正在阻止,我很好,在无限循环中无法接收任何消息,但是,直到上一个演员退出他们的无限循环之前,其他演员似乎才进入循环。这使我相信所有演员都在一个线程上。在解决方案上有什么想法吗?
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**
我已经实例化了100个演员(ID从1-100增加)。演员1-5立即在迭代后输入中断语句,但是当我打印ID时,它被卡在6中。打破演员循环的逻辑,其中ID = 6同时取决于其他演员行动。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
per thespian docs ::
这表明默认情况下,thespian可以有效地在同一线程中运行所有演员。
替代基础(例如
Multiproctcpbase
,除非您确定要Multiprocudpbase
或Multiprocqueuebase
)可以选择其他地方作为选择的基础。在启动时传递到actorsystem
。默认的siglystembase
没有并行性。Per Thespian's docs:
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 wantmultiprocUDPBase
ormultiprocQueueBase
) can be passed to theActorSystem
at startup. The defaultsimpleSystemBase
has no parallelism.