API Reference

actors module

class actors.Actor[source]

Bases: object

The base class implemented by all actors.

Variables:context (ActorContext) – Provides contextual information about this actor and the current message. Only valid within this actor.
context = None
post_restart()[source]

Called on the newly created actor.

post_stop()[source]

Called asynchronous after the actor has stopped.

pre_restart()[source]

Called on the failed actor before it’s disposed of.

pre_start()[source]

Called asynchronous before processing any messages.

receive(message)[source]

Override to provide the actor behaviour.

Parameters:message – The current message.
ref

Alias for self.context.self_ref.

sender

Alias for self.context.sender.

supervisor_strategy(exception)
class actors.ActorContext(system, supervisor)[source]

Bases: actors.internal.factory.ActorFactory

Provides contextual information to actors. Only valid within the Actor.receive() method.

Variables:
parent = None
self_ref = None
sender = None
stop()[source]
system = None
class actors.ActorSystem(system_dispatcher=None)[source]

Bases: actors.internal.factory.ActorFactory

dead_letters
terminate()[source]
class actors.ActorRef(_cell)[source]

Bases: object

tell(message, sender=None)[source]

Send a message to this actor. Asynchronous fire-and-forget.

Parameters:
  • message (Any) – The message to send.
  • sender (Actor) – The sender of the message. If provided it will be made available to the receiving actor via the Actor.sender attribute.
class actors.Directive[source]

Bases: object

Restart = 'restart'
Resume = <object object>
Stop = 'terminate'

actors.utils module

class actors.utils.AsyncCountDownLatch[source]

Bases: actors.actor.Actor

CountDown = <object object>
Done = <object object>
class Start(count)

Bases: tuple

count

Alias for field number 0

AsyncCountDownLatch.receive(message)[source]

actors.utils.ask module

class actors.utils.ask.PromiseActorRef[source]

Bases: actors.ref.ActorRef

tell(message, sender=None)[source]
actors.utils.ask.ask(actor, message)[source]

Send a message to actor and return a Future holding a possible reply.

To receive a result, the actor MUST send a reply to sender.

Parameters:
  • actor (ActorRef.) –
  • message
Returns:

A future holding the result.

actors.utils.proxy module

class actors.utils.proxy.Invoke(name, args, kwargs)

Bases: tuple

args

Alias for field number 1

kwargs

Alias for field number 2

name

Alias for field number 0

class actors.utils.proxy.ProxyActor[source]

Bases: actors.actor.Actor

receive(message)[source]
class actors.utils.proxy.ProxyRef(underlying)[source]

Bases: object

actors.utils.proxy.as_proxy(actor_ref)[source]

Create a proxy wrapper from an existing reference. The actor MUST implement the ProxyActor interface.

Parameters:actor_ref (ActorRef) – The actor reference.