Skip to content

Commit

Permalink
Wrap patched function
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzheng committed Sep 23, 2023
1 parent fdad298 commit fa1de53
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions aiohttp_requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

# Patch ClientResponse.read to release immediately after read so we don't need to worry about that / use context manager
_read_only = aiohttp.client_reqrep.ClientResponse.read
async def _read_and_release(self): # noqa
@functools.wraps(_read_only) # noqa
async def _read_and_release(self, *args, **kwargs):
try:
data = await _read_only(self)
data = await _read_only(self, *args, **kwargs)
finally:
self.close()

Expand Down

0 comments on commit fa1de53

Please sign in to comment.