Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #9405/b96b01b backport][3.10] Only create the connection closed exception once #9410

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,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 @@ -1188,7 +1191,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
Loading