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

Small cleanup to the connection check in ClientResponse #10035

Closed
wants to merge 6 commits into from
Closed
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
12 changes: 8 additions & 4 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,11 @@ def _response_eof(self) -> None:
return

# protocol could be None because connection could be detached
protocol = self._connection and self._connection.protocol
if protocol is not None and protocol.upgraded:
if (
self._connection is not None
and (protocol := self._connection.protocol)
and protocol.upgraded
):
return

self._closed = True
Expand Down Expand Up @@ -1152,8 +1155,9 @@ async def read(self) -> bytes:
elif self._released: # Response explicitly released
raise ClientConnectionError("Connection closed")

protocol = self._connection and self._connection.protocol
if protocol is None or not protocol.upgraded:
if self._connection is not None and (
(protocol := self._connection.protocol) is None or not protocol.upgraded
):
await self._wait_released() # Underlying connection released
return self._body

Expand Down
Loading