V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
watsy0007
V2EX  ›  Python

今天发现 1 个 io 爆表的 websocket 封装库, 大家有兴趣的可以看下.

  •  
  •   watsy0007 ·
    watsy0007 · Feb 10, 2020 · 3871 views
    This topic created in 2277 days ago, the information mentioned may be changed or developed.

    uWebSockets.py

    官方给的 benchmark

    perf

    代码

    import uws
    import asyncio
    
    # Integrate with asyncio
    asyncio.set_event_loop(uws.Loop())
    
    app = uws.App({
            "some": "option"
    })
    
    def getHandler(res, req):
    	res.end("Hello Python!")
    
    app.get("/*", getHandler)
    
    def listenHandler():
            print("Listening to port 3000")
    
    app.listen(3000, listenHandler)
    
    # Run asyncio event loop
    asyncio.get_event_loop().run_forever()
    
    2 replies    2020-02-11 11:04:14 +08:00
    watsy0007
        2
    watsy0007  
    OP
       Feb 11, 2020
    @xiadong1994 github 的图片好像不能预览
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1465 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 16:52 · PVG 00:52 · LAX 09:52 · JFK 12:52
    ♥ Do have faith in what you're doing.