【Thrift】python 例子
来源:互联网 发布:好压mac 编辑:程序博客网 时间:2024/06/05 23:06
service MyService{ string get()}
import socketimport syssys.path.append('./gen-py')from helloworld import MyServicefrom helloworld.ttypes import *from thrift.transport import TSocketfrom thrift.transport import TTransportfrom thrift.protocol import TBinaryProtocolfrom thrift.server import TServerclass HelloWorldHandler: def get(self): return "glgl"handler = HelloWorldHandler()processor = MyService.Processor(handler)transport = TSocket.TServerSocket("localhost", 9090)tfactory = TTransport.TBufferedTransportFactory()pfactory = TBinaryProtocol.TBinaryProtocolFactory()server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)print("Starting thrift server in python...")server.serve()print("done!")
import syssys.path.append('./gen-py')from helloworld import MyServicefrom thrift import Thriftfrom thrift.transport import TSocketfrom thrift.transport import TTransportfrom thrift.protocol import TBinaryProtocoltry: transport = TSocket.TSocket('localhost', 9090) transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) client = MyService.Client(protocol) transport.open() print("client - get") print("server - " + client.get()) transport.close()except Thrift.TException: print()
阅读全文
0 0
- python thrift简单例子
- 【Thrift】python 例子
- thrift C++做server, C++,python, java做Client例子
- thrift C++做server, C++,python, java做Client例子
- thrift开发的例子(一)---python为例
- thrift C++做server, C++,python, java做Client例子
- thrift python
- Python thrift
- Thrift CPP例子
- thrift一个例子
- thrift完整例子
- thrift一个例子
- thrift小例子
- Thrift简单例子
- Thrift 入门例子
- 【thrift】java 例子
- 分享下我学习Thrift的入门例子helloworld,客户端用php,服务端用python:
- 一个Thrift的简单例子
- 关于win7的VmWare虚拟机下安装CentiOS6.9 minimal过程
- 48. Rotate Image
- UVA 455 Periodic Strings
- 【快速搞定】2分钟搞定极光推送(极光推送Android端集成)
- HDU5738 Eureka
- 【Thrift】python 例子
- Android布局之layout_weight的用法
- 图解自考——数据结构导论概论
- HMM:隐马尔科夫
- Go语言学习笔记
- 七月英语总结
- 渣翻——Function、Method、Procedure和Subroutine的区别
- 斯坦福算法Specialization的收获
- 【深度学习】笔记10:Ubuntu16.04环境下配置caffe的步骤(无GPU版本)