GeventSocketIOWorker没有属性'socket'

时间:2013-02-01 23:31:54

标签: django socket.io gunicorn gevent-socketio

我需要使用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运行它,一切正常,我必须错过一些非常重要的东西。

感谢您的帮助

3 个答案:

答案 0 :(得分:9)

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

pip install gunicorn==0.16.1

答案 1 :(得分:0)

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

pip install gevent-socketio==0.3.6

答案 2 :(得分:0)

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

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