From e7ee74d6bba74cfd89b9ddc38f28e02514eb1791 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sat, 22 Mar 2025 19:01:48 +0000 Subject: [PATCH] Catch SSL crashes while writing the response (Fixes #206) --- src/microdot/microdot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/microdot/microdot.py b/src/microdot/microdot.py index 045000b..ae8c4ed 100644 --- a/src/microdot/microdot.py +++ b/src/microdot/microdot.py @@ -1336,9 +1336,9 @@ class Microdot: print_exception(exc) res = await self.dispatch_request(req) - if res != Response.already_handled: # pragma: no branch - await res.write(writer) try: + if res != Response.already_handled: # pragma: no branch + await res.write(writer) await writer.aclose() except OSError as exc: # pragma: no cover if exc.errno in MUTED_SOCKET_ERRORS: