Skip to content

Commit

Permalink
Small speed up to checking connection in ClientResponse
Browse files Browse the repository at this point in the history
The check should have been is not None here to avoid the __bool__ call
which is always True
  • Loading branch information
bdraco committed Oct 11, 2024
1 parent 5bded30 commit 073097f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ def _response_eof(self) -> None:
return

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

Expand Down Expand Up @@ -1140,7 +1140,7 @@ async def read(self) -> bytes:
elif self._released: # Response explicitly released
raise ClientConnectionError("Connection closed")

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

0 comments on commit 073097f

Please sign in to comment.