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
watsy0007
V2EX  ›  Python

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

  •  
  •   watsy0007 ·
    watsy0007 · 2020-02-10 14:58:40 +08:00 · 3019 次点击
    这是一个创建于 1508 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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 条回复    2020-02-11 11:04:14 +08:00
    xiadong1994
        1
    xiadong1994  
       2020-02-10 23:55:52 +08:00
    watsy0007
        2
    watsy0007  
    OP
       2020-02-11 11:04:14 +08:00
    @xiadong1994 github 的图片好像不能预览
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1909 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 16:25 · PVG 00:25 · LAX 09:25 · JFK 12:25
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.