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)
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)
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)