Skip to content
/ netcall Public
forked from aglyzov/netcall

Simple Python RPC system (ZeroMQ + IOLoop/Gevent)

License

Notifications You must be signed in to change notification settings

baojie/netcall

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetCall -- a simple Python RPC system

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.

Feature Overview

  • 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)

Example

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.

About

Simple Python RPC system (ZeroMQ + IOLoop/Gevent)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published