推荐学习书目
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 · Dec 1, 2017 · 3268 views
    This topic created in 3113 days ago, the information mentioned may be changed or developed.
    本人 python 新人爱好者一枚,现在可以自己写一些小 python 脚本提高日常工作效率。

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

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

    请问各位前辈,还有哪些方式可以实现类似想法。哪种方式更好一些?
    5 replies    2017-12-01 18:29:41 +08:00
    p2pCoder
        1
    p2pCoder  
       Dec 1, 2017
    RPC 和 http 都行
    数据传输的话,thrift 是一个不错的选择
    饿了么有开源的 thrift python 实现 https://github.com/eleme/thriftpy
    northisland
        2
    northisland  
       Dec 1, 2017
    我还记得 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
       Dec 1, 2017
    @p2pCoder
    @northisland

    谢谢两位的建议,思路开阔了很多。第一次了解到 ZeroMQ 感觉值得深入研究一下
    debuggerx
        4
    debuggerx  
       Dec 1, 2017
    之前写的远程调用,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  
       Dec 1, 2017
    mq 或者 celery 感觉都可以
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4884 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 04:00 · PVG 12:00 · LAX 21:00 · JFK 00:00
    ♥ Do have faith in what you're doing.