本文整理汇总了Python中pykka.registry.ActorRegistry.broadcast方法的典型用法代码示例。如果您正苦于以下问题:Python ActorRegistry.broadcast方法的具体用法?Python ActorRegistry.broadcast怎么用?Python ActorRegistry.broadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykka.registry.ActorRegistry
的用法示例。
在下文中一共展示了ActorRegistry.broadcast方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_broadcast_sends_message_to_all_actors_of_given_class_name
# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import broadcast [as 别名]
def test_broadcast_sends_message_to_all_actors_of_given_class_name(self):
ActorRegistry.broadcast({'command': 'foo'}, target_class='AnActor')
for actor_ref in ActorRegistry.get_by_class(self.AnActor):
received_messages = actor_ref.proxy().received_messages.get()
self.assert_({'command': 'foo'} in received_messages)
for actor_ref in ActorRegistry.get_by_class(self.BeeActor):
received_messages = actor_ref.proxy().received_messages.get()
self.assert_({'command': 'foo'} not in received_messages)
示例2: tell
# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import broadcast [as 别名]
def tell(self, message, safe=False):
"""
Send message to actor without waiting for any response.
Will generally not block, but if the underlying queue is full it will
block until a free slot is available.
:param message: message to send
:type message: picklable dict
:raise: :exc:`pykka.ActorDeadError` if actor is not available
:return: nothing
"""
if not self.is_alive():
if safe:
ActorRegistry.broadcast(DeadMessage(self, message), DeadMessageBox)
else:
raise ActorDeadError('%s not found' % self)
self.actor_inbox.put(message)
示例3: test_broadcast_sends_message_to_all_actors_if_no_target
# 需要导入模块: from pykka.registry import ActorRegistry [as 别名]
# 或者: from pykka.registry.ActorRegistry import broadcast [as 别名]
def test_broadcast_sends_message_to_all_actors_if_no_target(self):
ActorRegistry.broadcast({'command': 'foo'})
for actor_ref in ActorRegistry.get_all():
received_messages = actor_ref.proxy().received_messages.get()
self.assert_({'command': 'foo'} in received_messages)