Skip to content

Commit

Permalink
Fix ConnectionResetError not being raised when the transport is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jan 22, 2023
1 parent 4635161 commit eab15e3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aiohttp/http_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ def _write(self, chunk: bytes) -> None:
self.buffer_size += size
self.output_size += size

if self._transport is None or self._transport.is_closing():
# self._protocol.transport will be None if connection is closed
#
# We cannot check if self._transport is None here because
# we hold a reference to it even after the connection is closed.
#
if self._protocol.transport is None or self._transport.is_closing():
raise ConnectionResetError("Cannot write to closing transport")
self._transport.write(chunk)

Expand Down

0 comments on commit eab15e3

Please sign in to comment.