ThriftPy 是 Apache Thrift 的 Python 语言移植版本。
服务器端示例代码:
import thriftpy from thriftpy.rpc import make_server pingpong = 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 thriftpy from thrift.rpc import make_client pingpong = thriftpy.load("pingpong.thrift") client = make_client(pingpong.PingPong, '127.0.0.1', 6000) client.ping()