是否有推荐的方法在Python3上运行异步wsgi?

时间:2015-08-19 03:48:34

标签: python wsgi uwsgi gunicorn gevent

在Python3上,我不能将gevent用作wsgi 有没有办法像Python3上的gevent一样运行async 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.

2 个答案:

答案 0 :(得分:0)

为什么你不能使用' gevent'?有什么问题?

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

pip install 'gevent==1.1b3'

答案 1 :(得分:0)

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