mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-10-20 18:12:43 -04: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
|
# urllib's addinfourl does not close the underlying fp automatically when fully read
|
||||||
if isinstance(underlying, io.BytesIO):
|
if isinstance(underlying, io.BytesIO):
|
||||||
# data URLs or in-memory responses (e.g. gzip/deflate/brotli decoded)
|
# 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()
|
self.close()
|
||||||
elif isinstance(underlying, io.BufferedReader) and amt is None:
|
elif isinstance(underlying, io.BufferedReader) and amt is None:
|
||||||
# file URLs.
|
# file URLs.
|
||||||
|
|||||||
Reference in New Issue
Block a user