求教一些远程通信的问题? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
xboylegend
V2EX    Python

求教一些远程通信的问题?

  •  
  •   xboylegend 2017-12-01 09:37:14 +08:00 3022 次点击
    这是一个创建于 2953 天前的主题,其中的信息可能已经有所发展或是发生改变。
    本人 python 新人爱好者一枚,现在可以自己写一些小 python 脚本提高日常工作效率。

    最近想实现一些远程的数据传输与功能调用。例如将客户端采集或生成的数据传递给服务器做统一处理或反馈。

    现在能想到的方法一个是使用 SOCKET。又或者在远端的服务器用 python 实现 web api 来进行调用。

    请问各位前辈,还有哪些方式可以实现类似想法。哪种方式更好一些?
    5 条回复    2017-12-01 18:29:41 +08:00
    p2pCoder
        1
    p2pCoder  
       2017-12-01 09:42:03 +08:00
    RPC 和 http 都行
    数据传输的话,thrift 是一个不错的选择
    饿了么有开源的 thrift python 实现 https://github.com/eleme/thriftpy
    northisland
        2
    northisland  
       2017-12-01 10:45:09 +08:00
    我还记得 ZeroMQ 里的 4 种消息模式:

    1 对 1 PAIR
    客户端服务端 REQ-REP
    订阅多种消息推送 SUB-PUB
    生产者-消费者模式 PUSH-PULL

    好像 C++里还有 route 模式
    http://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/patterns/patterns.html
    xboylegend
        3
    xboylegend  
    OP
       2017-12-01 13:56:02 +08:00
    @p2pCoder
    @northisland

    谢谢两位的建议,思路开阔了很多。第一次了解到 ZeroMQ 感觉值得深入研究一下
    debuggerx
        4
    debuggerx  
       2017-12-01 14:34:53 +08:00
    之前写的远程调用,linux 运行 client 将写好的代码发送到 win 的 server,编译好后再返回到 linux 上。
    Server.py
    https://gist.github.com/anonymous/063f0e39a8f974946a05ed3e7d6e8b6e

    Client.py
    https://gist.github.com/anonymous/7f3f4c10a01a5694ff8bb4dd94341c0a

    方法虽然古老,最少够小够轻,python 自带都不用再额外装库就能稳定工作了
    fxxkgw
        5
    fxxkgw  
       2017-12-01 18:29:41 +08:00
    mq 或者 celery 感觉都可以
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2353 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 03:58 PVG 11:58 LAX 19:58 JFK 22:58
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86