Skip to content

Commit

Permalink
[PR #9405/b96b01b backport][3.11] Only create the connection closed e…
Browse files Browse the repository at this point in the history
…xception once (#9409)
  • Loading branch information
bdraco authored Oct 3, 2024
1 parent 4c67472 commit d93c78f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,9 @@ async def _on_headers_request_sent(
await trace.send_request_headers(method, url, headers)


_CONNECTION_CLOSED_EXCEPTION = ClientConnectionError("Connection closed")


class ClientResponse(HeadersMixin):

# Some of these attributes are None when created,
Expand Down Expand Up @@ -1178,7 +1181,7 @@ def _cleanup_writer(self) -> None:
def _notify_content(self) -> None:
content = self.content
if content and content.exception() is None:
set_exception(content, ClientConnectionError("Connection closed"))
set_exception(content, _CONNECTION_CLOSED_EXCEPTION)
self._released = True

async def wait_for_close(self) -> None:
Expand Down

0 comments on commit d93c78f

Please # to comment.