Skip to main content

ToRPC(Tornado + RPC) is a tiny tcp and duplex RPC implementation in Python based on Tornado IOLoop. It’s very lightweight and high performance(especially on PyPy).

Notice: ToRPC was only tested on CPython 2.7+ and PyPy 2.5+ until now.

## Examples

RPC server

from tornado import ioloop
from torpc import RPCServer
server = RPCServer(('127.0.0.1', 5000))

@server.service.register()
def echo(x):
    return x

server.start()
ioloop.IOLoop.instance().start()

RPC client

from tornado import ioloop, gen
from torpc import RPCClient

def result_callback(f):
    print(f.result())

@gen.coroutine
def using_gen_style():
    want_to_say = 'way to explore'
    ret = yield rc.call('echo', want_to_say)
    assert ret == want_to_say
    print('gen_style complete')

rc = RPCClient(('127.0.0.1', 5000))
rc.call('echo', 'hello world', callback=result_callback)
future = rc.call('echo', 'code for fun')
future.add_done_callback(result_callback)
using_gen_style()
ioloop.IOLoop.instance().start()

See more in examples.

Performance

OS: CentOS 6.6 x64 CPU: Intel i5-3470 3.20GHz Memory: 8 GB 1600 MHz DDR3 Python: 2.7.10 PyPy: 4.0.0

environment

call coroutine(qps)

callback(qps)

Python(with timeout)

9842

11614

Python

13192

16638

PyPy(with timeout)

40486

41225

PyPy

53252

59151

PyPy(unix domain)

67100

74362

In this benchmark, Python loops 100k times and PyPy loops 1000k times, then run 3 times of each, the result is on gist:benchmark_result.txt

Document

中文

Release files for torpc 0.0.1

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

Source distribution (sdist)

Source distribution for torpc 0.0.1
File Size Uploaded
torpc-0.0.1.tar.gz 6.6 kB Details

Release files / torpc-0.0.1.tar.gz

Download URL torpc-0.0.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0fbb98aaa35fe3d7f557c59ffd9cac1a2b504c3e83a29280d9041fa5c7cd9c01
BLAKE2b-256 checksum
How to use checksums
45c69fdb3d1344593beb10718204cde0f708ebdda0ee9c3bf329a111a4699c7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.1 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