Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Python Actor Middleware

Project Description

# **PyActor**
###### _The minimalistic python actor middleware_

PyActor is a python actor middleware for an object oriented architecture
constructed with the idea of getting two remote objects
to quickly communicate in a very simple, lightweight and minimalistic way.

It supports two versions:
* Threading
* Gevent green threads

<!-- +grafic tests -->

It also includes communication between machines using XMLRPC and a second version
that uses RabbitMQ message system in a just transparent way.

### Installation
Install using:

python install

Check that works executing the examples:

cd examples

Check also the docs for a tutorial:

[![Documentation Status](](

Commits are build and tested automatically at [Travis-CI](

[![Build Status](](

See code coverage at []( or [](

[![Coverage Status](](
<!-- [![Coverage Status](]( -->

The code is also checked for its health at every push by [](
(PEP8, common bad smells, etc.):

[![Code Health](](

## First steps

This library is implemented using two types of concurrence:

* ``'thread'`` : classic threads
* ``'green_thread'`` : Gevent

Green threads give a performance almost twice better.

You will need to specify which one you are going to use at the beginning of your
script with ``set_context('TYPE')``. Where type is one of the two keywords

Then, first of all, a `Host` is needed in order to create some actors.
Use it to spawn actors by giving the class type of the actor to create
and one string that will identify it among the host. See example:

h = create_host()
actor1 = h.spawn('id1', MyClass)

The class of an actor must have defined its methods in the _tell and _ask lists
so they can be called through the proxy. In the _tell list will be named those
methods meant to be asynchronous and in the _ask list, the synchronous ones.
In this example we have a class ``MyClass`` with a sync method *ask_me()* and an
async method *tell_me()*:

class MyClass:
_tell =['tell_me']
_ask = ['ask_me']
def tell_me(self, msg):
print msg
def ask_me(self):
return 'hello back'

As you can see, the async method receives a message and simply prints it while
the sync method returns a result. You can now call this methods from your main

print actor1.ask_me()

## Remote connections

Unlike other library solutions, PyActor supports remote communication between
various machines by only giving an IP to the host. For example:

host = create_host('')

An this host is online, so the other machine only needs to lookup for it:

host = create_host('')
remote_host = host.lookup_url('', Host)

Or directly get one of its actors:

c = host.lookup_url('', 'MyClass', 'module')

## Tutorial
PyActor has many examples and a tutorial explaining all its functionalities.
This examples can be found in the
'pyactor/examples' directory of the project. They are also explained in the
documentation as a tutorial, hosted at which you can find above.

Release History

This version
History Node


Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting