Recover from errors writing the response
This commit is contained in:
@@ -986,15 +986,17 @@ class Microdot():
|
|||||||
res = self.dispatch_request(req)
|
res = self.dispatch_request(req)
|
||||||
except Exception as exc: # pragma: no cover
|
except Exception as exc: # pragma: no cover
|
||||||
print_exception(exc)
|
print_exception(exc)
|
||||||
if res and res != Response.already_handled: # pragma: no branch
|
|
||||||
res.write(stream)
|
|
||||||
try:
|
try:
|
||||||
|
if res and res != Response.already_handled: # pragma: no branch
|
||||||
|
res.write(stream)
|
||||||
stream.close()
|
stream.close()
|
||||||
except OSError as exc: # pragma: no cover
|
except OSError as exc: # pragma: no cover
|
||||||
if exc.errno in MUTED_SOCKET_ERRORS:
|
if exc.errno in MUTED_SOCKET_ERRORS:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise
|
print_exception(exc)
|
||||||
|
except Exception as exc: # pragma: no cover
|
||||||
|
print_exception(exc)
|
||||||
if stream != sock: # pragma: no cover
|
if stream != sock: # pragma: no cover
|
||||||
sock.close()
|
sock.close()
|
||||||
if self.shutdown_requested: # pragma: no cover
|
if self.shutdown_requested: # pragma: no cover
|
||||||
|
|||||||
Reference in New Issue
Block a user