推荐学习书目
› 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
shenlei
V2EX  ›  Python

websocket 怎么实时发送数据到网页?

  •  
  •   shenlei · Jul 25, 2016 · 5946 views
    This topic created in 3714 days ago, the information mentioned may be changed or developed.

    我后台用的是 python 库中的一个 websocket 模块 simplewebsocketserver https://github.com/dpallot/simple-websocket-server ,在收到前台命令之后,会一次发送几十条数据:主要就是在 handleMessage 函数中循环调用 sendlemessage 函数,但是我发现在调用之后数据包并没有立即发送给 web 页面啊。这些数据实际上也的确是分开发送的,所以我怀疑是不是在退出 handlemessage 函数退出之后才开始发送数据?我想实现的就是立即发送给页面,不用等待。谢谢大家了。

    3 replies  •  2016-07-25 13:34:40 +08:00
    septem123
        1
    septem123  
       Jul 25, 2016
    这个时候你需要的是 socket.io
    我自己用的是 node 版的
    python 版的 https://github.com/miguelgrinberg/python-socketio
    Kilerd
        2
    Kilerd  
       Jul 25, 2016 via Android
    gevent websocket 也可以用一下
    Kilerd
        3
    Kilerd  
       Jul 25, 2016 via Android
    如果是 flask 可以用 flask socket s
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   844 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:56 · PVG 04:56 · LAX 13:56 · JFK 16:56
    ♥ Do have faith in what you're doing.