This is a simple Python RPC system using ZeroMQ as a transport and supporting various concurrency techniques: Python Threading, Tornado/IOLoop, Gevent, Eventlet, Greenhouse,
Initially the code was forked from ZPyRPC in Feb 2014. The fork has added support for Python Threading and various Greenlet environments, refactored code, made incompatible API changes, added new features and examples.
- Reasonably fast
- Simple hackable code
- Really easy API
- Auto load balancing of multiple services (thanks to ZeroMQ)
- Full ZeroMQ routing as a bonus
- Asynchronous servers (Threading, Tornado/IOLoop, Gevent, Eventlet, Greenhouse)
- Both synchronous and asynchronous clients (Threading, Tornado/IOLoop, Gevent, Eventlet, Greenhouse)
- Ability to set a timeout on RPC calls
- Ability to run multple services in a single process
- Pluggable serialization (Pickle [default], JSON, MessagePack)
To create a service:
from netcall.tornado import TornadoRPCService
echo = TornadoRPCService()
@echo.task
def echo(self, s):
return s
echo.register(lambda n: "Hello %s" % n, name='hello')
echo.bind('tcp://127.0.0.1:5555')
echo.bind('ipc:///tmp/echo.service') # multiple endpoints
echo.start()
echo.serve()
To talk to this service:
from netcall.threading import ThreadingRPCClient
p = ThreadingRPCClient()
p.connect('tcp://127.0.0.1:5555')
p.connect('ipc:///tmp/echo.service') # auto load balancing
p.echo('Hi there')
'Hi there'
p.hello('World')
'Hello World'
See other examples.