ThriftPy是ApacheThrift的Python语言移植版本。
服务器端示例代码:
import thriftpyfrom thriftpy.rpc import make_serverpingpong = thriftpy.load("pingpong.thrift")class Dispatcher(object): def ping(self): return "pong"server = make_server(pingpong.PingPong, Dispatcher(), '127.0.0.1', 6000)server.serve()客户端:
import thriftpyfrom thrift.rpc import make_clientpingpong = thriftpy.load("pingpong.thrift")client = make_client(pingpong.PingPong, '127.0.0.1', 6000)client.ping()
评论