Git Product home page Git Product logo

zmqrpc-geoffwatts's Introduction

ZMQRPC

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

Installation

zmqrpc is registered at pypi.

Install using pip or easy_install:

$> pip install zmqrpc

Prerequisites

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.

Usage

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)
    server.queue('tcp://0.0.0.0:5000',thread=True)
    server.work(workers=2)

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://127.0.0.1:5000",timeout=5)
    for i in range(5000):
        x = rpc.test()

    print x
    servers = rpc.__serverstatus__()
    pprint.pprint(servers)

Usage Notes

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

zmqrpc-geoffwatts's People

Contributors

fredrik avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.