Skip to main content

ezrpc

Easy to use ZeroMQ based RPC library.

https://pypip.in/v/ezrpc/badge.png https://pypip.in/d/ezrpc/badge.png

Install

pip install ezrpc

Quickstart

Step 1

Create a Server

# server.py
from ezrpc import Server

# By default, the server binds to all available interfaces
s = Server(server_port=5000, client_port=5001)
s.start()

Run this with:

python server.py

Step 2

Create a Worker

# worker.py
from ezrpc import Registry, ServerWorker
registry = Registry()

@registry.method
def add(a, b):
        return a + b

@registry.method
def multiply(a, b):
        return a * b

# Point the worker to the Server's IP
w = ServerWorker(sys.argv[1], registry, "tcp://127.0.0.1:5000")
w.run()

Run as many workers as your server can handle:

python worker.py worker1
python worker.py worker2
python worker.py worker3

Workers are elastic, i.e. you can start and stop them at will and clients will continue to be served.

Step 3

Create a Client

# client.py
from ezrpc import Client

# Point the client to the Server's IP
# timeout (millis) is optional, default is 5 seconds
c = Client('tcp://127.0.0.1:5001', timeout=1000)

for i in range(1,11):
        res = c.ask('add', i, 1)
        print 'Response: %s' % res

c._disconnect()

Run the client

python client.py

Metadata

Release files for ezrpc 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezrpc 0.1.0
File Size Uploaded
ezrpc-0.1.0.tar.gz 4.0 kB Details

Release files / ezrpc-0.1.0.tar.gz

Download URL ezrpc-0.1.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4b05d7f974578f78c1ca12017a301d54849d1874d3f3570c0b81dccf54793c8d
BLAKE2b-256 checksum
How to use checksums
c9b7aa50dbf1a969670077eb7b87a54ecf778b0fb59a6277af231fd203eda8e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page