From deb34a29674ab3c21a71f416c7a108ddf0cf9136 Mon Sep 17 00:00:00 2001 From: Humberto Rocha Date: Wed, 24 Aug 2022 02:22:00 -0400 Subject: [PATCH] Remove cyclic references in HTTP implementations (#1604) * Remove parser reference to break the cyclic reference to protocol and let garbage colletor to do it's work * Unset keepalive after closing transport --- uvicorn/protocols/http/h11_impl.py | 1 + uvicorn/protocols/http/httptools_impl.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/uvicorn/protocols/http/h11_impl.py b/uvicorn/protocols/http/h11_impl.py index 905de3de14..5fff70bb7d 100644 --- a/uvicorn/protocols/http/h11_impl.py +++ b/uvicorn/protocols/http/h11_impl.py @@ -145,6 +145,7 @@ def connection_lost(self, exc: Optional[Exception]) -> None: self.flow.resume_writing() if exc is None: self.transport.close() + self._unset_keepalive_if_required() def eof_received(self) -> None: pass diff --git a/uvicorn/protocols/http/httptools_impl.py b/uvicorn/protocols/http/httptools_impl.py index 715b9e2a02..f018c59af3 100644 --- a/uvicorn/protocols/http/httptools_impl.py +++ b/uvicorn/protocols/http/httptools_impl.py @@ -137,6 +137,9 @@ def connection_lost(self, exc: Optional[Exception]) -> None: self.flow.resume_writing() if exc is None: self.transport.close() + self._unset_keepalive_if_required() + + self.parser = None def eof_received(self) -> None: pass