How should I detect if a client has disconnected from my gevent webserver if I use a queue to generate response data? Right now I keep getting the Broken pipe
error, but I don't quite understand where I should catch this exception (the traceback only includes gevent's own pywsgi.py
and socket.py
files and none of my code). Thanks.
I'm not sure how to do that if you're returning a queue from your WSGI app (If I understood correctly what you're doing).
If you can structure your application in a different way and use WSGI's write() then you can catch socket exceptions like this:
def application(environ, start_response):
write = start_response('200 OK', [])
try:
write("response")
except socket.error, ex:
print ex