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 · 2341 次点击
    这是一个创建于 2331 天前的主题,其中的信息可能已经有所发展或是发生改变。
    本人 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   ·   我们的愿景   ·   实用小工具   ·   2744 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 14:45 · PVG 22:45 · LAX 07:45 · JFK 10:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.