explicitly close opened url

This commit is contained in:
Kovid Goyal 2025-09-22 12:30:53 +05:30
parent 53e2f00473
commit 4e240b94e1
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -68,7 +68,8 @@ def download_with_retry(url: str | Request, count: int = 5) -> bytes:
for i in range(count):
try:
print('Downloading', url, flush=True)
ans: bytes = urlopen(url).read()
with urlopen(url) as f:
ans: bytes = f.read()
return ans
except Exception as err:
if i >= count - 1: