Code Monkey home page Code Monkey logo

zpyrpc's Introduction

ZPyRPC = "Zippy RPC"

Zippy fast and simple RPC based on ZeroMQ and Python

Overview

This library provides a simple, but fast and robust RPC library for ZeroMQ. It was originally designed in the context of IPython, but we eventually spun it out into its own project.

Some of the nice features:

  • Round robin load balance requests to multiple services.
  • Set a timeout on RPC calls.
  • Route requests using all of the glory of ZeroMQ.
  • Fast, but simple.
  • Both synchronous and asynchronous clients/proxies.
  • Run multple services in a single process.
  • Pluggable serialization (default is pickle, json included).

Example

To create a simple service:

from zpyrpc import RPCService
class Echo(RPCService):

    @rpc_method
    def echo(self, s):
        return s

echo = Echo()
echo.bind('tcp://127.0.0.1:5555')
IOLoop.instance().start()

To talk to this service::

from zpyrpc import RPCServiceProxy
p = RPCServiceProxy()
p.connect('tcp://127.0.0.1:5555')
p.echo('Hi there')
'Hi there'

zpyrpc's People

Contributors

ellisonbg avatar minrk avatar sjagoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

zpyrpc's Issues

Unable to (cleanly) terminate process using zpyrpc in Python 3.4

(using PR #2) Using Python 3.4, the below script hangs on exit of the IOLoop unless a service.socket.close() is present. This was not required in Python 2.7 or 3.3.

import signal
from zpyrpc import RPCService
from zpyrpc import JSONSerializer

from zmq.eventloop import ioloop

loop = ioloop.IOLoop.instance()


def handler(signal, frame):
    print('Shutting down on signal {}'.format(signal))
    loop.stop()

signal.signal(signal.SIGINT, handler)
signal.signal(signal.SIGTERM, handler)

service = RPCService(serializer=JSONSerializer())

print('Running')
loop.start()
# Uncomment to prevent hang
# service.socket.close()
print('Stopping')

async_client.py does not exit

Should the async client exit when finished or is the hanging I'm experiencing at the end normal behavior? I'd like for it to cleanly exit after all messages have been received. Is that possible?

CENTOS 6.6
python 2.6
zeromq 3.2.4
pyzmq 2.2.0.1

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.