MessagePack RPC implementation based on Tornado.
% pip install msgpack-rpc-pythonor
% python setup.py install- msgpack-python (>= 0.3)
- tornado (>= 3)
import msgpackrpc
class SumServer(object):
def sum(self, x, y):
return x + y
server = msgpackrpc.Server(SumServer())
server.listen(msgpackrpc.Address("localhost", 18800))
server.start()import msgpackrpc
client = msgpackrpc.Client(msgpackrpc.Address("localhost", 18800))
result = client.call('sum', 1, 2) # = > 3In test directory:
% PYTHONPATH=../ python test/test_msgpackrpc.pyRun with timeout test(Timeout test takes about 5 seconds)
% PYTHONPATH=../ python test/test_msgpackrpc.py --timeout-testOS: Mac OS X ver 10.8.3
CPU: Intel Core i7 2.7 GHz
Memory: 16 GB 1600 MHz DDR3
| call(QPS) | async(QPS) | notify(QPS) | |
|---|---|---|---|
| 2.7.3 | 5903 | 6040 | 24877 |
| 3.3.0 | 5493 | 5812 | 23634 |
| PyPy 1.9.0 with GCC 4.2.1 | 5519 | 9729 | 46406 |
Test code are available in example directory(bench_client.py and bench_server.py).
- Add advanced return to Server.
- UDP, UNIX Domain support
- Utilities (MultiFuture, SessionPool)
| Author | Masahiro Nakagawa |
| Copyright | Copyright (c) 2011- Masahiro Nakagawa |
| License | Apache License, Version 2.0 |