【一】调通单机版的thrift-python版本
开发步骤说明

【任务1】调通单机版的thrift-python版本
安装thrift
下载源码包
wget http://apache.fayea.com/thrift/0.9.3/thrift-0.9.3.tar.gz安装thrift [进入thrift目录]
- 运行命令:
yum install openssl-devel.x86_64[可选择是否安装] - 运行命令:
yum install boost-devel.x86_64[必须安装] - 运行命令:
./configure --with-cpp --with-boost --with-python --without-csharp --with-java --without-erlang --without-perl --with-php --without-php_extension --without-ruby --without-haskell --without-go - 运行命令:
yum install boost-devel-static - 运行命令:
make,make isntall
- 运行命令:
安装thrift对python的支持模块
pip install thrift==0.9.3
创建thrift模块文件并编译
- 创建RecSys.thrift文件 [创建到任意目录]
service RecSys {
string rec_data(1:string data)
}
- 命令:
thrift --gen py RecSys.thrift,此时在当前目录中会产生gen-py的文件夹,其中有当前的模块名字
开发python版的client和server
- 创建 server.py 文件测试
import sys
sys.path.append('../schema/gen-py/')
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from RecSys import RecSys
from thrift.server import TServer
from RecSys.ttypes import *
class RecSysHandler(RecSys.Iface):
def rec_data(self, a):
print "Receive: %s" %(a)
return "I`m OK !!!"
if __name__ == "__main__":
# 实例化handler
handler = RecSysHandler()
# 设置processor
processor = RecSys.Processor(handler)
# 设置端口
transport = TSocket.TServerSocket('localhost', port=9900)
# 设置传输层
tfactory = TTransport.TBufferedTransportFactory()
# 设置传输协议
pfactory = TBinaryProtocol.TBinaryProtocolFactory()
handler = RecSysHandler()
server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
print 'Starting the server...'
server.serve()
print 'done'
- 创建 client.py 文件测试
#coding=utf-8
import sys
sys.path.append('../schema/gen-py/')
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from RecSys import RecSys
if __name__ == "__main__":
# 设置端口
transport = TSocket.TSocket('localhost', port=9900)
# 设置传输层
transport = TTransport.TBufferedTransport(transport)
# 设置传输协议
protocol = TBinaryProtocol.TBinaryProtocol(transport)
client = RecSys.Client(protocol)
transport.open()
rs = client.rec_data("are you ok ??")
print "receive return data: ", rs
transport.close()
【一】调通单机版的thrift-python版本的更多相关文章
- 【二】调通单机版的thrift-C++版本
[任务2]调通单机版的thrift-C++版本 [任务2]调通单机版的thrift-C++版本 创建文件 安装boost开发工具 拷贝文件 [可忽略此步骤,如果c++代码直接编译无误的话] 编译 创建 ...
- 全志R58平台调通s5k5eya(RAW+MIPI)
全志R58平台调通s5k5eya(RAW+MIPI) 2017/5/31 10:30 版本:V1.1 1.前期使用的是s5k5eyx的ISP的固件/tuning 文件 Y:\s5k5eya_r58_d ...
- CentOS7 下升级Python版本
来博客园的第一篇博客,以后要坚持养成记录.分享的习惯啊,这样生活才会有痕迹~ 服务器版本:CentOS 7.3 64位 旧Python版本:2.7.5 新Python版本:3.8.0 说明:本次配置使 ...
- 2016最后一贴,终于调通一个测试示例,并发现一个BUG???
真的难点在于第一次调通.纠结五天,终于搞出界面. 也发现了一个书上代码,编辑用户时死活不通的情况,我将Links去了,改在data里,我X,,全OK了.. 原来的代码: onAdd: function ...
- 提取bmp图片的颜色信息,可直接framebuffer显示(c版本与python版本)
稍微了解了下linux的framebuffer,这是一种很简单的显示接口,直接写入像素信息即可 配置好的内核,会有/dev/fbn 的接口,于是想能否提前生成一个文件,比如logo.fb,里面仅包含像 ...
- Centos7下安装python,查看python版本
安装Centos的时候,一般会自带默认安装python2.x 一般用python -V可以查看python版本. 我当时安装的时候,运行了那个语句,但是却显示了一大堆出来,虽然里面也带有版本信息,但是 ...
- LInux升级Python版本2.7.11所遇问题汇总
首先请原谅我使用校园网络,基本上打不开谷歌,网络搜取得帮助均来自度娘. 对于我这个linux新手 IT 新手来说,自己升级点东西好担心,万一出错,可能都要重来.... 参照度娘内容和自己摸索,今天晚上 ...
- Sublime Text 2 增加python版本
当系统中装有多个python版本时,Sublime Text 2 使用哪个版本需要手动添加 键入一下内容,path输入python的安转路径 保存至Python27.sublime-build文件 ...
- linux 多个python版本的切换
源码安装新的python版本,我的安装路径: /usr/self/Python3.5.2 修改软链接到你所安装的python版本中: 默认python命令是在/usr/bin/目录下 1 sudo m ...
随机推荐
- HTML,javascript,image等加载,DOM解析,js执行生命周期
- windows远程桌面无法粘贴复制的解决方法
案例一:未勾选剪贴板,进入 远程桌面连接选项“本地资源->本地设备和资源->剪贴板”中,勾选剪贴板. 案例二:已勾选剪贴板,但是无法粘贴复制,进入远程服务器,关闭[rdpclip.exe] ...
- 十个免费的 Web 压力测试工具
本文列举了是十个免费工具,可以用来进行Web的负载/压力测试的.这样你就可以知道你的服务器以及你的WEB应用能够扛得住多少的并发量,以及网站性能. 0. Grinder – Grinder是一个开源 ...
- Web API 2 入门——使用ASP.NET Web API和Angular.js构建单页应用程序(SPA)(谷歌翻译)
在这篇文章中 概观 演习 概要 由网络营 下载网络营训练包 在传统的Web应用程序中,客户机(浏览器)通过请求页面启动与服务器的通信.然后,服务器处理请求,并将页面的HTML发送给客户端.在与页面的后 ...
- 【Leetcode】【Medium】Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that ...
- 六种排序算法的JavaScript实现以及总结
最近几天在系统的复习排序算法,之前都没有系统性的学习过,也没有留下过什么笔记,所以很快就忘了,这次好好地学习一下. 首先说明为了减少限制,以下代码通通运行于Node V8引擎而非浏览器,源码在我的Gi ...
- WebSphere集群环境修改IHS端口号的方法
参考资料:http://wenku.baidu.com/link?url=E9BkuEjJ16i9lg7l91L0-xhKCYkHV0mAnlwAeSlDCFM4TjZyk4ZVxmUu64BGd4F ...
- 鲁宾斯坦说:"思维是在概括中完成的。"
鲁宾斯坦说:"思维是在概括中完成的."
- ADF中遍历VO中的行数据(Iterator)
在ADF中VO实质上就是一个迭代器, 1.在Application Module的实现类中,直接借助VO实现类和Row的实现类 TestVOImpl organizationUser = (TestV ...
- 解决pycharm无法导入本地包的问题
在用python写爬虫程序时,import 行无法通过,具体情况如下: pycharm运行程序后,程序pass了,但是出现了警告,如下图所示: 这是由于该程序不在根目录下,无法导入本地包,解决办法如下 ...