mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-10-20 04:56:34 +09:00
[rh:urllib] Eagerly release BytesIO responses (#17717)
Authored by: doe1080
This commit is contained in:
1 parent
9dd5e68cd7
commit
f9eee6ba62
1 file changed
+3
-1
@@ -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