Close HTTP loop when connection task cancelled (#2245)

* Terminate loop when no transport exists

* Add log when closing HTTP loop because of shutdown

* Add unit test
This commit is contained in:
Adam Hopkins
2021-09-27 10:22:30 +03:00
committed by GitHub
parent d9796e9b1e
commit 595d2c76ac
4 changed files with 54 additions and 7 deletions

View File

@@ -109,7 +109,7 @@ class HttpProtocol(SanicProtocol, metaclass=TouchUpMeta):
except Exception:
error_logger.exception("protocol.connection_task uncaught")
finally:
if self.app.debug and self._http:
if self.app.debug and self._http and self.transport:
ip = self.transport.get_extra_info("peername")
error_logger.error(
"Connection lost before response written"