Python 带有gevent worker服务器的Gunicorn在一段时间后挂起

Python 带有gevent worker服务器的Gunicorn在一段时间后挂起,python,sockets,nginx,gunicorn,gevent,Python,Sockets,Nginx,Gunicorn,Gevent,在服务器运行一段时间后,我将获得此stacktrace 2014-02-12 23:42:14[28012][错误]错误处理请求 Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/gunicorn/workers/async.py", line 39, in handle self.handle_request(req, client, addr) File "/usr/lib/pymodu

在服务器运行一段时间后,我将获得此stacktrace 2014-02-12 23:42:14[28012][错误]错误处理请求

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/gunicorn/workers/async.py", line 39, in handle
    self.handle_request(req, client, addr)
  File "/usr/lib/pymodules/python2.7/gunicorn/workers/ggevent.py", line 86, in handle_request
    super(GeventWorker, self).handle_request(*args)
  File "/usr/lib/pymodules/python2.7/gunicorn/workers/async.py", line 74, in handle_request
    resp.write(item)
  File "/usr/lib/pymodules/python2.7/gunicorn/http/wsgi.py", line 255, in write
    self.send_headers()
  File "/usr/lib/pymodules/python2.7/gunicorn/http/wsgi.py", line 251, in send_headers
    util.write(self.sock, "%s\r\n" % "".join(tosend))
  File "/usr/lib/pymodules/python2.7/gunicorn/util.py", line 235, in write
    sock.sendall(data)
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 509, in sendall
    data_sent += self.send(_get_memory(data, data_sent), flags)
  File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 483, in send
    return sock.send(data, flags)
error: [Errno 32] Broken pipe
我使用gunicorn+nginx作为服务器。这是我的gunicorn配置:

workers = 5
worker_class = 'egg:gunicorn#gevent'
worker_connections = 1000
timeout = 3600
keepalive = 2
我甚至不确定这个stacktrace是否是服务器挂起的实际原因,因为在这个stacktrace之后会显示2-3个其他get请求(当服务器重新启动时正常工作的get请求),并且不会生成更多的日志

另外,过了一段时间后,我不断收到错误“included urlconf中没有任何模式”。当服务器重新启动时,不会发生这种情况。我已经分别测试了所有的URL,它们似乎工作正常


任何帮助都将不胜感激。

请向我们展示您的一些代码。我们需要看看您是如何处理套接字错误的。我不会从代码端处理任何套接字错误。一切都取决于gunicorn worker配置。这是除了配置之外我应该做的事情吗?如果你不处理套接字错误,你将得到未处理的异常。除非您向我们展示您正在运行的代码,否则无法提供帮助。该代码是一个约20k行的项目。我到底应该显示哪个部分我没有明确连接/写入任何套接字。这纯粹是gevent+gunicorn,当我面对工作挂起时,它为我的http请求提供服务。通过使用runserver而不是gunicorn+gevent,我能够顺利运行同一个项目(尽管它不可扩展)