Skip to content

Commit

Permalink
Remove cyclic references in HTTP implementations (#1604)
Browse files Browse the repository at this point in the history
* Remove parser reference to break the cyclic reference to protocol and let garbage colletor to do it's work

* Unset keepalive after closing transport
  • Loading branch information
humrochagf committed Aug 24, 2022
1 parent 9cd609e commit 91c1306
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions uvicorn/protocols/http/h11_impl.py
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions uvicorn/protocols/http/httptools_impl.py
Expand Up @@ -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
Expand Down

0 comments on commit 91c1306

Please sign in to comment.