Speedy - 一個快速的Python RPC系統

jopen 12年前發布 | 114K 次閱讀 RPC XML-RPC 開發

一個快速的,非阻塞,基于JSON的Python RPC系統,包含客戶端與服務器端。速度非當快可以達到(~50k-requests/s)。

##### 服務器端

class MyHandler(object):
    def foo(self, handle, arg1, arg2):
        handle.done(do_something(arg1, arg2))

import rpc.server
s = rpc.server.RPCServer('localhost', 9999, handler=MyHandler())
s.start()

客戶端
import rpc.client
c = rpc.client.RPCClient('localhost', 9999)
future = c.foo('Some data', 'would go here')
assert future.wait() == 'Expected result.'</pre> <p><strong>項目主頁:</strong><a href="http://www.baiduhome.net/lib/view/home/1352190736625" target="_blank">http://www.baiduhome.net/lib/view/home/1352190736625</a></p>
 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!