本文整理汇总了Python中pykka.ActorRegistry.broadcast方法的典型用法代码示例。如果您正苦于以下问题:Python ActorRegistry.broadcast方法的具体用法?Python ActorRegistry.broadcast怎么用?Python ActorRegistry.broadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykka.ActorRegistry
的用法示例。
在下文中一共展示了ActorRegistry.broadcast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_broadcast_sends_message_to_all_actors_of_given_class
# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import broadcast [as 别名]
def test_broadcast_sends_message_to_all_actors_of_given_class(self):
ActorRegistry.broadcast({'command': 'foo'}, target_class=self.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: test_broadcast_sends_message_to_all_actors_if_no_target
# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import broadcast [as 别名]
def test_broadcast_sends_message_to_all_actors_if_no_target(
a_actor_refs, b_actor_refs
):
ActorRegistry.broadcast({'command': 'foo'})
running_actors = ActorRegistry.get_all()
assert running_actors
for actor_ref in running_actors:
received_messages = actor_ref.proxy().received_messages.get()
assert {'command': 'foo'} in received_messages
示例3: test_broadcast_sends_message_to_all_actors_of_given_class_name
# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.ActorRegistry import broadcast [as 别名]
def test_broadcast_sends_message_to_all_actors_of_given_class_name(
actor_a_class, actor_b_class
):
ActorRegistry.broadcast({'command': 'foo'}, target_class='ActorA')
for actor_ref in ActorRegistry.get_by_class(actor_a_class):
received_messages = actor_ref.proxy().received_messages.get()
assert {'command': 'foo'} in received_messages
for actor_ref in ActorRegistry.get_by_class(actor_b_class):
received_messages = actor_ref.proxy().received_messages.get()
assert {'command': 'foo'} not in received_messages
示例4: test_broadcast_sends_message_to_all_actors_if_no_target
# 需要导入模块: from pykka import ActorRegistry [as 别名]
# 或者: from pykka.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)