Commit a8d8384b authored by Denis Bilenko's avatar Denis Bilenko

pywsgi: better patch for #82: do not close the connection if it's possible to reply with 500 reply

parent 439226fa
...@@ -436,11 +436,7 @@ class WSGIHandler(object): ...@@ -436,11 +436,7 @@ class WSGIHandler(object):
try: try:
try: try:
self.run_application() self.run_application()
except GreenletExit: except:
self.close_connection = True
raise
except Exception:
self.close_connection = True
self.handle_error(*sys.exc_info()) self.handle_error(*sys.exc_info())
finally: finally:
if hasattr(self.result, 'close'): if hasattr(self.result, 'close'):
...@@ -450,8 +446,12 @@ class WSGIHandler(object): ...@@ -450,8 +446,12 @@ class WSGIHandler(object):
self.log_request() self.log_request()
def handle_error(self, type, value, tb): def handle_error(self, type, value, tb):
self.server.loop.handle_error(self.environ, type, value, tb) if not issubclass(type, GreenletExit):
if not self.response_length: self.server.loop.handle_error(self.environ, type, value, tb)
del tb
if self.response_length:
self.close_connection = True
else:
self.start_response(_INTERNAL_ERROR_STATUS, _INTERNAL_ERROR_HEADERS) self.start_response(_INTERNAL_ERROR_STATUS, _INTERNAL_ERROR_HEADERS)
self.write(_INTERNAL_ERROR_BODY) self.write(_INTERNAL_ERROR_BODY)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment