Commit ff9d2895 authored by Denis Bilenko's avatar Denis Bilenko

wsgi: fix issue #58: even if http_request instance is leaked, reply with 500...

wsgi: fix issue #58: even if http_request instance is leaked, reply with 500 error immediatelly when application raises an error. Thanks to Jon Aslund.
parent b855435a
......@@ -117,6 +117,7 @@ class WSGIHandler(object):
if hasattr(result, 'close'):
result.close()
except GreenletExit:
self._reply500()
raise
except:
traceback.print_exc()
......@@ -125,14 +126,17 @@ class WSGIHandler(object):
(self.server, self.request, self.server.application))
except Exception:
pass
# do not call self.end so that core.http replies with 500
self = None
return
self._reply500()
finally:
sys.exc_clear()
if self is not None and self.code is not None:
self.end(env)
def _reply500(self):
self.reason = None
self.start_response('500 Internal Server Error', [('Content-Type', 'text/plain')])
self.write('Internal Server Error')
class WSGIServer(HTTPServer):
"""A fast WSGI server based on :class:`HTTPServer`."""
......
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