Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ActorProxy from actor's self.actor_ref #9

jodal opened this issue Apr 22, 2012 · 0 comments

Create ActorProxy from actor's self.actor_ref #9

jodal opened this issue Apr 22, 2012 · 0 comments


Copy link

@jodal jodal commented Apr 22, 2012

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()   # will never return

Even though we don't block on any future here, the 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.
@jodal jodal closed this in 76c9306 Sep 18, 2012
@ghost ghost assigned jodal Sep 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant