Python Gunicorn工人定期撞车:';套接字未注册';

Python Gunicorn工人定期撞车:';套接字未注册';,python,gunicorn,Python,Gunicorn,gunicorn worker不时(每隔几个小时一次)出现故障,出现以下错误: [2014-10-29 10:21:54 +0000] [4902] [INFO] Booting worker with pid: 4902 [2014-10-29 13:15:24 +0000] [4902] [ERROR] Exception in worker process: Traceback (most recent call last): File "/opt/test/env/local/lib

gunicorn worker不时(每隔几个小时一次)出现故障,出现以下错误:

[2014-10-29 10:21:54 +0000] [4902] [INFO] Booting worker with pid: 4902
[2014-10-29 13:15:24 +0000] [4902] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/opt/test/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
    worker.init_process()
  File "/opt/test/env/local/lib/python2.7/site-packages/gunicorn/workers/gthread.py", line 109, in init_process
    super(ThreadWorker, self).init_process()
  File "/opt/test/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 120, in init_process
    self.run()
  File "/opt/test/env/local/lib/python2.7/site-packages/gunicorn/workers/gthread.py", line 177, in run
    self.murder_keepalived()
  File "/opt/test/env/local/lib/python2.7/site-packages/gunicorn/workers/gthread.py", line 149, in murder_keepalived
    self.poller.unregister(conn.sock)
  File "/opt/test/env/local/lib/python2.7/site-packages/trollius/selectors.py", line 408, in unregister
    key = super(EpollSelector, self).unregister(fileobj)
  File "/opt/test/env/local/lib/python2.7/site-packages/trollius/selectors.py", line 243, in unregister
    raise KeyError("{0!r} is not registered".format(fileobj))
KeyError: '<socket._socketobject object at 0x7f823f454d70> is not registered'
...
...
[2014-10-29 13:15:24 +0000] [4902] [INFO] Worker exiting (pid: 4902)
[2014-10-29 13:15:24 +0000] [5809] [INFO] Booting worker with pid: 5809
 ...
我正在使用:

Python 2.7.6
gunicorn==19.1.1
trollius==1.0.2
futures==2.2.0
你知道原因是什么以及如何解决吗


谢谢

我遇到了类似的问题,我从gunicorn工人那里得到了超时错误。我正在使用sync worker,并且有
超时
保持激活
默认设置。 在我的用例中,我的http请求需要很长时间才能完成,因此同步工作者超时。我使用
curl
作为发送http-1.1请求的http客户端。我将超时时间增加到了一个疯狂的高值,即1小时,可以正常工作。然而,在服务器错误日志中,我看到了与您相同的错误。这是我关于这个错误的假设。 由于默认情况下,所有http 1.1请求都是持久性的,所以服务器尝试通过将连接放回队列来重用连接,但不超过
keepalive
timeout。因此,当发生
keepalive
timeout时,它会注销套接字,使其无法重用,并将其关闭。现在,由于我的超时值非常高,服务器尝试多次注销一个已经未注册的套接字,但是keepalive仍然默认为5秒,所以会出错。因此,我将``keepalive
值也增加到了
3600``。到目前为止,它起了作用

# http://gunicorn-docs.readthedocs.org/en/latest/settings.html
timeout = 3600 # one hour timeout for long running jobs
keepalive = 3600

大约一年前,我报告了一个gunicorn bug,应该在gunicorn 19.6.0及更高版本中进行修复:

这方面有什么进展吗?我面临着完全相同的情况!不,仍然在等待社区的帮助。我不确定,因为我必须进行更多的调查,但我认为这可能与套接字在注销之前关闭有关。我打算增加优雅的超时时间,看看会发生什么。将在此处更新:)
# http://gunicorn-docs.readthedocs.org/en/latest/settings.html
timeout = 3600 # one hour timeout for long running jobs
keepalive = 3600