You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sending messages to one self is a common way of implementing recursion using actors. This is doable in Pykka using e.g.:
self.actor_ref.tell({'some': 'message'})
Obviously, blocking on getting the value from a future encapsulating a result calculated by one self will deadlock the actor, as the actor will not be able to respond to the message while waiting for the response. It's biting its own tail:
future=self.actor_ref.ask({'some': 'message'})
future.get() # will never return
Analogous, it would be nice to be able to create an ActorProxy around self.actor_ref and call methods on the proxy instead of sending plain messages. As @zombiecalypse discovered and pointed out in a mail to me February 17, this currently doesn't work. An example:
proxy=self.actor_ref.proxy()
proxy.foo() # will never return
Even though we don't block on any future here, the proxy.foo() method call will never return. This is because the proxy object on it's first use will query the actor about what fields and methods it has available before it performs the method call or field access it was asked to do.
To make the above code work, we need to either:
Rewrite the proxy implementation so that we don't need to ask about available methods and fields first. Some of the work may be done on the receiving side of the call. Some of the work may be done by looking at the callees class, with the possible loss of free access to dynamically added attributes.
Or, we can special-case the creation of a proxy to itself. Since the actor has full access to itself, it can preseed the proxy object with information about itself, so that the proxy never needs to ask for what attributes exist, and thus never block.
The text was updated successfully, but these errors were encountered:
Sending messages to one self is a common way of implementing recursion using actors. This is doable in Pykka using e.g.:
Obviously, blocking on getting the value from a future encapsulating a result calculated by one self will deadlock the actor, as the actor will not be able to respond to the message while waiting for the response. It's biting its own tail:
Analogous, it would be nice to be able to create an
ActorProxy
aroundself.actor_ref
and call methods on the proxy instead of sending plain messages. As @zombiecalypse discovered and pointed out in a mail to me February 17, this currently doesn't work. An example:Even though we don't block on any future here, the
proxy.foo()
method call will never return. This is because the proxy object on it's first use will query the actor about what fields and methods it has available before it performs the method call or field access it was asked to do.To make the above code work, we need to either:
The text was updated successfully, but these errors were encountered: