ToRPC(Torado+RPC)是一个的基于ToradoIOLoop的异步TCP和双向通信的RPC的Pytho实现。ToRPC非常轻量级,性能优秀(尤其是在PyPy环境下)。
注意:目前为止,ToRPC只在CPytho2.7+和PyPy2.5+上测试过。
示例RPC服务器
fromtoradoimportioloopfromtorpcimportRPCServerserver=RPCServer(('127.0.0.1',5000))@server.service.register()defecho(x):returxserver.start()ioloop.IOLoop.istace().start()RPC客户端
fromtoradoimportioloop,gefromtorpcimportRPCClietdefresult_callback(f):prit(f.result())@ge.coroutiedefusig_ge_style():wat_to_say='waytoexplore'ret=yieldrc.call('echo',wat_to_say)assertret==wat_to_sayprit('ge_stylecomplete')rc=RPCCliet(('127.0.0.1',5000))rc.call('echo','helloworld',callback=result_callback)future=rc.call('echo','codeforfu')future.add_doe_callback(result_callback)usig_ge_style()ioloop.IOLoop.istace().start()更多请浏览examples。
Performace系统:CetOS6.6x64
处理器:Iteli5-34703.20GHz
内存:8GB1600MHzDDR3
Pytho:2.7.10PyPy:4.0.0
evirometcallcoroutie(qps)callback(qps)Pytho(withtimeout)984211614Pytho1319216638PyPy(withtimeout)4048641225PyPy5325259151PyPy(uixdomai)6710074362这个基准测试中,Pytho循环10w次,PyPy循环50w次,然后运行3次,结果在gist:bechmark_result.txt










评论