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

Python flask + uwsgi flask-sockets 部署出现 KeyError: 'wsgi.websocket'? 有没有使用过 flask-sockets 或者 gevent-websocket 的大佬

  •  
  •   sccyzc · Jul 16, 2020 · 1834 views
    This topic created in 2262 days ago, the information mentioned may be changed or developed.

    [uwsgi] uid=root gid=root socket = 0.0.0.0:9024 chdir=/root/test-scc/scc_service master=true vhost = True workers = 2 enable-threads = True wsgi-file= run.py callable = flask_app module=run:flask_app logto=/var/error.log python-autoreload=1 touch-chain-reload = true uwsgi_read_timeout = 600 limit-as = 6048 processes=4 gevent= 100

    采用 uwsgi 部署成功后: 1.http 接口可以正常访问 2.ws 接口异常:environment = environ['wsgi.websocket'] KeyError: 'wsgi.websocket' 如下方式启动服务不会出现上诉问题: if name == 'main': from gevent import pywsgi from geventwebsocket.handler import WebSocketHandler

    host, port, debug = configuration.get_start_config()
    flask_app.debug = eval(debug)
    
    server = pywsgi.WSGIServer((host, int(port)), flask_app,   handler_class=WebSocketHandler)
    server.serve_forever()
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2562 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 12:48 · PVG 20:48 · LAX 05:48 · JFK 08:48
    ♥ Do have faith in what you're doing.