【问题标题】:Is there recommended way to run async wsgi on Python3?是否有推荐的方法在 Python3 上运行异步 wsgi?
【发布时间】:2015-11-12 04:55:40
【问题描述】:

在 Python3 上,我不能将 gevent 用作 wsgi。
有什么方法可以在 Python3 上运行像 gevent 这样的异步 wsgi。
我使用 wsgi 作为 gunicorn 并在 CentOS 6.6 上运行。

当我用 gunicorn 尝试 gevent 1.1b3 时,我得到了这些错误。

$ python manage.py gunicorn -k gevent
[2015-08-19 14:20:48 +0900] [13636] [INFO] Starting gunicorn 19.3.0
[2015-08-19 14:20:48 +0900] [13636] [INFO] Listening at: http://127.0.0.1:8000 (13636)
[2015-08-19 14:20:48 +0900] [13636] [INFO] Using worker: gevent
[2015-08-19 14:20:48 +0900] [13640] [INFO] Booting worker with pid: 13640
[2015-08-19 14:20:48 +0900] [13640] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 185, in init_process
    self.patch()
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 74, in patch
    _sock=s))
TypeError: __init__() got an unexpected keyword argument '_sock'
Traceback (most recent call last):
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 185, in init_process
    self.patch()
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/gunicorn/workers/ggevent.py", line 74, in patch
    _sock=s))
TypeError: __init__() got an unexpected keyword argument '_sock'
[2015-08-19 14:20:48 +0900] [13640] [INFO] Worker exiting (pid: 13640)
[2015-08-19 14:20:48 +0900] [13636] [INFO] Shutting down: Master
[2015-08-19 14:20:48 +0900] [13636] [INFO] Reason: Worker failed to boot.

【问题讨论】:

    标签: python wsgi uwsgi gunicorn gevent


    【解决方案1】:

    为什么不能使用“gevent”?有什么问题?

    是的,Python 3 支持目前处于测试阶段,但我相信 gevent 开发人员很乐意听到即将推出的 Python 3 支持的任何问题。

    pip install 'gevent==1.1b3'
    

    【讨论】:

    • 您或许应该在 gunicorn 的 github 问题跟踪器或 IRC 上的 gunicorn 组上与 gunicorn 开发人员讨论这个问题。如,这似乎是 gunicorn 和最新的 gevent beta 版本的问题。他们很可能有一个修复,但尚未在发布的 gunicorn 版本中。
    • 我发现已经有人提交了拉取请求,并被合并到 gunicorn 上的 master 中。 github.com/benoitc/gunicorn/pull/1066 我还发现 eventlet 在 python3 上与 gunicorn 配合得很好。
    【解决方案2】:

    我遇到了同样的问题。将 gunicorn 升级到最新版本 19.4.5 解决了该问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-04
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多