我有一个python服务器,主要有:
from gevent import pywsgi
try:
httpd = pywsgi.WSGIServer(('0.0.0.0', 8000), app)
httpd.serve_forever()
except KeyboardInterrupt:
pass
最近我们开始获取HTTPError: 504 Server Error: Gateway Time-out
对服务器的请求。看着日志,我看到了这个:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 508, in handle_one_response
self.run_application()
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 495, in run_application
self.process_result()
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 486, in process_result
self.write(data)
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 380, in write
self._write_with_headers(data)
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 400, in _write_with_headers
self._sendall(towrite)
File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 355, in _sendall
self.socket.sendall(data)
File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 460, in sendall
data_sent += self.send(_get_memory(data, data_sent), flags)
File "/usr/local/lib/python2.7/dist-packages/gevent/socket.py", line 437, in send
return sock.send(data, flags)
error: [Errno 32] Broken pipe
{'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': '*/*',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_CONNECTION': 'close',
'HTTP_HOST': 'bekku.bbmsc.com',
'HTTP_USER_AGENT': 'python-requests/2.9.1',
'HTTP_X_FORWARDED_FOR': '192.168.10.5',
'HTTP_X_REAL_IP': '192.168.10.5',
'PATH_INFO': '/readings',
'QUERY_STRING': 'target=2225217193085335062&tool=HM',
'REMOTE_ADDR': '172.17.42.1',
'REMOTE_PORT': '41708',
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': '',
'SERVER_NAME': 'fdffcd119506',
'SERVER_PORT': '8000',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SOFTWARE': 'gevent/1.0 Python/2.7',
'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7f4c299bc1e0>,
'wsgi.input': <gevent.pywsgi.Input object at 0x7f4c19e55210>,
'wsgi.multiprocess': False,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)} failed with error
一旦发生这种情况,似乎没有提供进一步的请求。我搜索了这个,发现很多地方人们说这种情况发生了,很多地方人们解释了为什么会发生这种情况,但没有地方我找到了修复或解决这个问题的方法。
有没有人知道如何在发生这种情况后让它继续处理?