parley/proxy.py - reference and communicate with spawned actors.
parley/helpers.py - helper classes and functions for constructing actors.
Indicates a generic failure during an RPC call.
This exception indicates that the remote actor responded to a message by sending an exception.
Raise this exception to cause an actor to terminate normally.
def become(target, *args, **kwargs):
Call the target function, keeping the same actor ID. This is currently equivalent to calling the target function directly, except that it transfers control without increasing the stack size. This is useful in cases of unbounded recursion. In the future, this function may also be used to change the mode or site of execution without changing the actor ID.
Create a bidirectional link to the target actor. If one linked actor terminates abnormally, the other will raise an AbnormalExit exception upon its next call to recv(). Similarly, if one actor terminates normally, a quit message will be sent to the other.
Return the actor proxy associated with the given name. Raises NoSuchActor if the name has not been registered.
Return a proxy object for the currently running actor.
Return a waiting message for the current actor, or block (allowing other threads to continue) until a message is available. The optional msg_filter argument should accept a message as an argument and return True or False to determine whether to return the message or leave it for later. If any actor linked to the current actor terminates abnormally, this method will raise AbnormalExit instead of returning.
Like recv, but returns None instead of blocking if no message is available. In the future, arbitrary timeouts will likely be supported.
def register(target, name):
Register the target actor proxy as being available under the given name.
Register a given actor controller object as the global actor controller. Normally, you will call start_tasklet_controller or start_thread_controller instead of this function; this function exists for those implementing some sort of alternative actor initialization scheme.
Check for signals and yield control of execution. In a preemptive execution model, this function does nothing except check for signals. In a cooperative model, this function also gives other actors a chance to run.
Set the internal name of the current actor. This is not any sort of globally reachable ID; this name is just to identify the actor for debugging purposes (e.g. if trace_on() has been called).
def spawn(actor, *args, **kwargs):
Spawn a new actor in a new thread of execution. This function returns an ActorProxy object that can be used to reference the spawned actor and communicate with it. As with the built-in "apply" function, the first argument can be any callable object, and remaining arguments are forwarded to that function.
def spawn_link(actor, *args, **kwargs):
Spawn a new actor and link the current actor to it. Equivalent to: a=spawn(...) link(a) but executed atomically: i.e., the spawned actor will not be started until it has been linked to the calling actor.
def start_greenlet_controller(entry_point, *args, **kwargs):
def start_tasklet_controller(entry_point, *args, **kwargs):
Start the tasklet controller and spawn the actor given by entry_point (forwarding args and kwargs to entry_point).
def start_thread_controller(entry_point, *args, **kwargs):
Start the thread controller and spawn the actor given by entry_point (forwarding args and kwargs to entry_point).
Stop the tracing of sent messages.
def trace_on(out_file=<open file '<stdout>', mode 'w'>):
Cause sent messages to be printed to the specified file. If no file is specified, stdout is used.
Cancel the bidirectional link to the target actor.
Unregister the actor proxy associated with the given name.