Q: Broken pipe from gevent/pywsgi.py I have a python server that has this in the main:
from gevent import pywsgi

try:
    httpd = pywsgi.WSGIServer(('0.0.0.0', 8000), app)
    httpd.serve_forever()
except KeyboardInterrupt:
    pass

Recently we began getting HTTPError: 504 Server Error: Gateway Time-out on requests to the server. Looking in the logs I saw this:
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

Once this occurs it seems that no further requests are served. I googled this and found many places where people said this was happening, and many places where people explained why it was happening, but no place did I find a way to fix or workaround this. 
Does anyone know how to get it to continue processing after this occurs? 
