MessagePack RPC for Python
MessagePack RPC implementation based on Tornado.
Installation
% python setup.py install
or
% easy_install msgpack-rpc-python
Dependent modules
- msgpack-python (>= 0.1.12)
- tornado (>= 2.1.1)
Example
Server
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()
Client
import msgpackrpc
client = msgpackrpc.Client(msgpackrpc.Address("localhost", 18800))
result = client.call('sum', 1, 2) # = > 3
Run test
In test directory:
% PYTHONPATH=../ python test_msgpackrpc.py
Run with timeout test(Timeout test takes about 5 seconds)
% PYTHONPATH=../ python test_msgpackrpc.py --timeout-test
Performance
OS: Mac OS X ver 10.8.2
CPU: Intel Core i7 2GHz
Memory: 8GB 1600MHz DDR3
Request(QPS) | Notify(QPS) | |
---|---|---|
2.7.2 | 4782 | 18315 |
3.2.3 | 4700 | 16667 |
Test code are available in example directory(bench_client.py and bench_server.py).
TODO
- Add advanced and async return to Server.
- UDP, UNIX Domain support
- Utilities (MultiFuture, SessionPool)
- Support pyev for performance if needed
Copyright
Author | Masahiro Nakagawa |
Copyright | Copyright (c) 2011- Masahiro Nakagawa |
License | Apache License, Version 2.0 |