mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-10-16 13:38:07 -07:00
[rh:urllib] Eagerly release BytesIO responses (#17717)
Authored by: doe1080
This commit is contained in:
@@ -313,7 +313,9 @@ class UrllibResponseAdapter(Response):
|
||||
# urllib's addinfourl does not close the underlying fp automatically when fully read
|
||||
if isinstance(underlying, io.BytesIO):
|
||||
# data URLs or in-memory responses (e.g. gzip/deflate/brotli decoded)
|
||||
if underlying.tell() >= len(underlying.getbuffer()):
|
||||
with underlying.getbuffer() as view:
|
||||
fully_read = underlying.tell() >= len(view)
|
||||
if fully_read:
|
||||
self.close()
|
||||
elif isinstance(underlying, io.BufferedReader) and amt is None:
|
||||
# file URLs.
|
||||
|
||||
Reference in New Issue
Block a user