Catch SSL crashes while writing the response (Fixes #206)

This commit is contained in:
Miguel Grinberg
2025-03-22 19:01:48 +00:00
parent 847dfd1321
commit e7ee74d6bb

View File

@@ -1336,9 +1336,9 @@ class Microdot:
print_exception(exc) print_exception(exc)
res = await self.dispatch_request(req) res = await self.dispatch_request(req)
if res != Response.already_handled: # pragma: no branch
await res.write(writer)
try: try:
if res != Response.already_handled: # pragma: no branch
await res.write(writer)
await writer.aclose() await writer.aclose()
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: