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

Closed
jodal opened this issue Apr 22, 2012 · 0 comments
Closed

Create ActorProxy from actor's self.actor_ref #9

jodal opened this issue Apr 22, 2012 · 0 comments
Assignees

Comments

@jodal
Copy link
Owner

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()
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.
@jodal jodal closed this as completed 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
Projects
None yet
Development

No branches or pull requests

1 participant