def test_actor_may_be_unregistered_multiple_times_without_error(self): ActorRegistry.unregister(self.ref) self.assertTrue(self.ref not in ActorRegistry.get_all()) ActorRegistry.unregister(self.ref) self.assertTrue(self.ref not in ActorRegistry.get_all()) ActorRegistry.register(self.ref) self.assertTrue(self.ref in ActorRegistry.get_all())
def test_actor_may_be_unregistered_multiple_times_without_error(self): ActorRegistry.unregister(self.ref) self.assert_(self.ref not in ActorRegistry.get_all()) ActorRegistry.unregister(self.ref) self.assert_(self.ref not in ActorRegistry.get_all()) ActorRegistry.register(self.ref) self.assert_(self.ref in ActorRegistry.get_all())
def test_actor_may_be_registered_manually(actor_ref): ActorRegistry.unregister(actor_ref) assert actor_ref not in ActorRegistry.get_all() ActorRegistry.register(actor_ref) assert actor_ref in ActorRegistry.get_all()
def test_actor_may_be_registered_manually(actor_ref): ActorRegistry.unregister(actor_ref) assert actor_ref not in ActorRegistry.get_all() ActorRegistry.register(actor_ref) assert actor_ref in ActorRegistry.get_all()
def test_actor_may_be_unregistered_multiple_times_without_error(actor_ref): ActorRegistry.unregister(actor_ref) assert actor_ref not in ActorRegistry.get_all() ActorRegistry.unregister(actor_ref) assert actor_ref not in ActorRegistry.get_all() ActorRegistry.register(actor_ref) assert actor_ref in ActorRegistry.get_all()
def iap(pid): g = Greeter.start() g.actor_urn = pid ActorRegistry.unregister(g) ActorRegistry.register(g) #greeter2 = Greeter.start(1).proxy() #greeter3 = Greeter.start(2).proxy() #greeter4 = Greeter.start(3).proxy() #greeter5 = Greeter.start(4).proxy() #a = ActorRegistry.get_all() #for i in a: # ppid = i.proxy().pid.get() # print (ppid, type(ppid)) # if ppid == '123': # print('haha, got you') # else: # print(ppid) for i in ActorRegistry.get_all(): print ('here') print(i.proxy().actor_urn.get(), type(i.proxy().actor_urn.get())) if i.proxy().actor_urn.get() == pid: print ('haha, got you') print ('=============') a = ActorRegistry.get_by_urn(pid) print (a) print ('=============') for i in ActorRegistry.get_all(): print(i) print (i.__dict__) print ('here') print(i.proxy().actor_urn.get(), type(i.proxy().actor_urn.get())) if i.proxy().actor_urn.get() == 'asdf': print ('haha, got you') #future = greeter.pprint({'message':'%s' % pid}) return 'as'
def __init__(self, name, min_exchange: int = 1, consumptions: List[Consumption] = [], productions: List[Production] = [], borders: List[Border] = []): super().__init__() self.name = name self.broker = Broker(name=name, tell=self.tell_to, ask=self.ask_to, min_exchange=min_exchange, consumptions=consumptions, productions=productions, borders=borders) self.waiter = Waiter() self.events = [] self.actor_ref.actor_urn = name ActorRegistry.register(self.actor_ref)
def start(cls, *args, **kwargs): """ Start an actor and register it in the :class:`ActorRegistry <pykka.ActorRegistry>`. Any arguments passed to :meth:`start` will be passed on to the class constructor. Behind the scenes, the following is happening when you call :meth:`start`: 1. The actor is created: 1. :attr:`actor_urn` is initialized with the assigned URN. 2. :attr:`actor_inbox` is initialized with a new actor inbox. 3. :attr:`actor_ref` is initialized with a :class:`pykka.ActorRef` object for safely communicating with the actor. 4. At this point, your :meth:`__init__()` code can run. 2. The actor is registered in :class:`pykka.ActorRegistry`. 3. The actor receive loop is started by the actor's associated thread/greenlet. :returns: a :class:`ActorRef` which can be used to access the actor in a safe manner """ obj = cls(*args, **kwargs) assert obj.actor_ref is not None, ( 'Actor.__init__() have not been called. ' 'Did you forget to call super() in your override?' ) ActorRegistry.register(obj.actor_ref) logger.debug('Starting {}'.format(obj)) obj._start_actor_loop() return obj.actor_ref
def start(cls, *args, **kwargs): """ Start an actor and register it in the :class:`ActorRegistry <pykka.ActorRegistry>`. Any arguments passed to :meth:`start` will be passed on to the class constructor. Behind the scenes, the following is happening when you call :meth:`start`: 1. The actor is created: 1. :attr:`actor_urn` is initialized with the assigned URN. 2. :attr:`actor_inbox` is initialized with a new actor inbox. 3. :attr:`actor_ref` is initialized with a :class:`pykka.ActorRef` object for safely communicating with the actor. 4. At this point, your :meth:`__init__()` code can run. 2. The actor is registered in :class:`pykka.ActorRegistry`. 3. The actor receive loop is started by the actor's associated thread/greenlet. :returns: a :class:`ActorRef` which can be used to access the actor in a safe manner """ obj = cls(*args, **kwargs) assert obj.actor_ref is not None, ( 'Actor.__init__() have not been called. ' 'Did you forget to call super() in your override?') ActorRegistry.register(obj.actor_ref) logger.debug('Starting {}'.format(obj)) obj._start_actor_loop() return obj.actor_ref
def test_actor_may_be_registered_manually(self): ActorRegistry.unregister(self.ref) self.assert_(self.ref not in ActorRegistry.get_all()) ActorRegistry.register(self.ref) self.assert_(self.ref in ActorRegistry.get_all())
def on_start(self): self.actor_ref.actor_urn = self.actor_urn ActorRegistry.unregister(self.actor_ref) ActorRegistry.register(self.actor_ref)
def test_actor_may_be_registered_manually(self): ActorRegistry.unregister(self.ref) self.assertTrue(self.ref not in ActorRegistry.get_all()) ActorRegistry.register(self.ref) self.assertTrue(self.ref in ActorRegistry.get_all())
def on_start(self): self.actor_ref.actor_urn = self.actor_urn ActorRegistry.unregister(self.actor_ref) ActorRegistry.register(self.actor_ref)