4

我需要使用 gunicorn 运行 Django 应用程序。我阅读了文档,并且我认为我应该设置所有内容,但是当我运行时

gunicorn --worker-class socketio.sgunicorn.GeventSocketIOWorker app.wsgi:application

我收到以下错误消息

2013-02-01 18:25:17 [25394] [INFO] Booting worker with pid: 25394
2013-02-01 18:25:18 [25394] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File ".../app-root/data/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
    worker.init_process()
  File ".../app-root/data/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 131, in init_process
    super(GeventWorker, self).init_process()
  File ".../app-root/data/lib/python2.7/site-packages/gunicorn/workers/base.py", line 104, in init_process
    self.run()
  File ".../app-root/data/lib/python2.7/site-packages/socketio/sgunicorn.py", line 14, in run
    self.socket.setblocking(1)
AttributeError: 'GeventSocketIOWorker' object has no attribute 'socket'
Traceback (most recent call last):
  File ".../app-root/data/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
    worker.init_process()
  File ".../data/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 131, in init_process
    super(GeventWorker, self).init_process()
  File ".../app-root/data/lib/python2.7/site-packages/gunicorn/workers/base.py", line 104, in init_process
    self.run()
  File ".../app-root/data/lib/python2.7/site-packages/socketio/sgunicorn.py", line 14, in run
    self.socket.setblocking(1)
AttributeError: 'GeventSocketIOWorker' object has no attribute 'socket'
2013-02-01 18:25:18 [25394] [INFO] Worker exiting (pid: 25394)

如果我用 django_socketio 运行它,一切正常,我一定会错过一些非常重要的东西。

谢谢您的帮助

4

3 回答 3

9

似乎是 gunicorn>0.17 的问题,请参阅问题 #122。对我来说,它正在使用版本 0.16.1 的 gunicorn。

pip install gunicorn==0.16.1
于 2013-02-03T10:08:25.727 回答
0

安装 gevent-socketio 0.3.6 可能会解决此问题,而无需在某些情况下恢复 gunicorn。我有 0.3.5-rc2 并且升级为我解决了这个问题(注意:这不在 django 中,但它有效。)

pip install gevent-socketio==0.3.6

于 2015-04-06T21:55:39.180 回答
0

由gunicorn的这种变化引起的。 https://github.com/benoitc/gunicorn/commit/9a83d719b23fe28667a9c76bac25ba66651f8ccf

以前用于 gevent worker 的套接字来自 gunicorn 套接字,现在它们包装了 gevent 协作套接字。所以恢复到旧版本的 gunicorn 并不是一个好主意。可能是禁用将禁用此检查的 Flash Policy Server。

于 2015-05-22T19:07:09.493 回答