Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
75 lines (44 sloc) 1.63 KB


A Python library that exports a class for RPC via zmq, using BSON for data interchange.


zmqrpc is registered at pypi.

Install using pip or easy_install:

$> pip install zmqrpc


Contributing and Enhancements

Go for it, fork away and fix it up. There's a lot of performance tweaks that can be made, this is very much 0.1

Most notably, I think the bson encoding should happen inside pyzmq.


A basic server:

This server will listen on TCP port 5000, and start 2 worker threads for the class Test

    class Test(object):

        def __init__(self):
            self.count = 0

        def test(self):
            self.count += 1
            return self.count        

    from zmqrpc.server import ZMQRPCServer, LISTEN, CONNECT

    server = ZMQRPCServer(Test)

A basic client:

This client connects to our server, then runs the test() method 5000 times. It then prints the last output of rpc.test(), and pprint's the server status.

    from zmqrpc.client import ZMQRPC 
    import sys
    import pprint

    rpc = ZMQRPC("tcp://",timeout=5)
    for i in range(5000):
        x = rpc.test()

    print x
    servers = rpc.__serverstatus__()

Usage Notes

This library is still very early. The API is likely to change.