GeventSocketIOWorker has no attribute 'socket'

亡梦爱人 提交于 2019-12-01 05:01:39

问题


I need to run Django application using gunicorn. I read documentation, and I think I set up everything like I should, but when I run

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

I get following error message

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)

If I run it with django_socketio, everything works fine, I must miss something really important.

Thank you for your help


回答1:


Seems to be a problem with gunicorn>0.17, see issue #122. For me it's working with the version 0.16.1 of gunicorn.

pip install gunicorn==0.16.1



回答2:


It's possible that installing gevent-socketio 0.3.6 might fix this without having to revert gunicorn for some cases. I had 0.3.5-rc2 and upgrading fixed this issue for me (NOTE: this was not in django, but it worked.)

pip install gevent-socketio==0.3.6




回答3:


Caused by this change in gunicorn. https://github.com/benoitc/gunicorn/commit/9a83d719b23fe28667a9c76bac25ba66651f8ccf

Previously the sockets used for gevent worker came from gunicorn socket now they wrap gevent cooperative sockets. So reverting to an older version of gunicorn is not good idea. May be disable Flash Policy Server that will disable this check.



来源:https://stackoverflow.com/questions/14656841/geventsocketioworker-has-no-attribute-socket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!