Skip to content

Commit

Permalink
Remove patch and let garbage collector reap/close the responses (if n…
Browse files Browse the repository at this point in the history
…ot already closed by reading to eof)
  • Loading branch information
maxzheng committed Sep 24, 2023
1 parent eb18580 commit bfb87b7
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions aiohttp_requests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import aiohttp
import functools

# 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
@functools.wraps(_read_only) # noqa
async def _read_and_release(self, *args, **kwargs):
try:
data = await _read_only(self, *args, **kwargs)
finally:
self.close()

return data
aiohttp.client_reqrep.ClientResponse.read = _read_and_release


class Requests:
""" Thin wrapper for aiohttp.ClientSession with Requests simplicity """
Expand Down

0 comments on commit bfb87b7

Please sign in to comment.