mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-09 03:21:51 +00:00
[rh:requests] Do not allocate 2GB on read (#13603)
Fixes c2ff2dbaec7929015373fe002e9bd4849931a4ce Authored by: Grub4K
This commit is contained in:
parent
e99c0b838a
commit
c316416b97
@ -143,7 +143,9 @@ class RequestsResponseAdapter(Response):
|
||||
# Work around issue with `.read(amt)` then `.read()`
|
||||
# See: https://github.com/urllib3/urllib3/issues/3636
|
||||
if amt is None:
|
||||
amt = (1 << 31) - 1
|
||||
# Python 3.9 preallocates the whole read buffer, read in chunks
|
||||
read_chunk = functools.partial(self.fp.read, 1 << 20, decode_content=True)
|
||||
return b''.join(iter(read_chunk, b''))
|
||||
# Interact with urllib3 response directly.
|
||||
return self.fp.read(amt, decode_content=True)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user