Python Makefile Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


pseud Latest Version Code Health

Pythonic bidirectional-rpc API built on top of ØMQ with pluggable encryption, authentication and heartbeating support.


  1. ØMQ transport layer.
  2. All native python types supported (msgpack).
  3. First citizen exceptions.
  4. Bi-bidirectional (server can initiate calls to connected clients).
  5. Encryption based on CURVE.
  6. Pluggable Authentication.
  7. Pluggable Heartbeating.
  8. Pluggable Remote Call Routing.
  9. Works with tornado ioloop or gevent.
  10. Built-in proxy support. A server can delegate the work to another one.
  11. SyncClient (using zmq.REQ) to use within non event based processes. (Heartbeating, Authentication and job execution are not supported with the SyncClient.)


Dependencies are declared in and all automatically installed, but, pyzmq might build libzmq from bundled folder OR from your system wide libzmq. In later case you should make sure libzmq has been compiled with libsodium to take advantage of curve security features.

libzmq 4.1 is now required. As it is not yet bundled within pyzmq you will need to compile it yourself. Also libsodium is a required dependency of pseud.

For ubuntu distribution, a ppa exists.

$ sudo add-apt-repository -y ppa:shnatsel/dnscrypt
$ sudo apt-get update -q && sudo apt-get install -y libsodium-dev
$ curl -L >
$ sh -c 'unzip; cd zeromq4-1; sh; ./configure --with-libsodium; make -j; sudo make install; sudo ldconfig'

Then you can install latest pyzmq from pypi

$ pip install pyzmq --install-option="--zmq=/usr/local"

Choose your backend

Pseud can be used with either tornado or gevent. As they can not be used both as the same time, you need to decide which one you want to use on installation time.


$ pip install "pseud[Tornado]"


$ pip install "pseud[Gevent]"


If both backends are installed (like in developer environment), tornado is used by default. To force gevent over tornado, set the environment variable $NO_TORNADO to something.

$ NO_TORNADO=1 python


The tornado Server

from pseud import Server

server = Server('service')

def hello(name):
    return 'Hello {0}'.format(name)

server.start()  # this will block forever

The tornado Client

# Assume the tornado IOLoop is running
from pseud import Client

client = Client('service', io_loop=loop)

# Assume we are inside a coroutine
response = yield client.hello('Charly')
assert response == 'Hello Charly'

The gevent Client

from pseud import Client

client = Client('service')

assert client.hello('Charly').get() == 'Hello Charly'

The SyncClient

# to use within a non-asynchronous process or in a command interpreter
from pseud import SyncClient

client = SyncClient()

assert client.hello('Charly') == 'Hello Charly'

The Server send a command to the client

It is important to note that the server needs to know which peers are connected to it. This is why the security_plugin trusted_peer comes handy. It will register all peer id and be able to route messages to each of them.

from pseud import Server

server = Server('service', security_plugin='trusted_peer')

def hello(name):
    return 'Hello {0}'.format(name)

server.start()  # this will block forever

The client needs to send its identity to the server. This is why plain security plugin is used. The server will not check the password, he will just take into consideration the user_id to perform the routing.

from pseud import Client

client = Client('service',

# Action that the client will perform when
# requested by the server.
def sheep():
    return 'beeeh'

# The client needs to perform a first call
# to the server in order to register itself.
# on production this will be handle automatically
# by the heartbeat backend. The first heartbeat will
# trigger the authentication. Then until the client
# disconnect the server will not ask the client
# to reconnect.

# assume we are inside a coroutine
result = yield client.hello('alice')
assert result == 'Hello alice'

Back on server side, now the client as registered itself, we can send to it any commands the client is able to do.

# assume we are inside a coroutine
sheep = yield server.send_to('alice')
assert sheep == 'beeeh'


Pseud on Readthedocs