Bug 1821513 - set a timeout for fetch-content downloads. r=releng-reviewers,gbrown

Setting a timeout on the download means we can retry if the connection
hangs, instead of sitting around idle until the task itself hits its
maxRunTime.

Differential Revision: https://phabricator.services.mozilla.com/D173287
This commit is contained in:
Julien Cristau 2023-03-23 07:11:20 +00:00
Родитель c6a93ac62f
Коммит 2ad2b6612b
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -183,8 +183,8 @@ def stream_download(url, sha256=None, size=None):
t0 = time.time()
with urllib.request.urlopen(
url, cafile=certifi.where()
) if certifi else urllib.request.urlopen(url) as fh:
url, timeout=60, cafile=certifi.where()
) if certifi else urllib.request.urlopen(url, timeout=60) as fh:
if not url.endswith(".gz") and fh.info().get("Content-Encoding") == "gzip":
fh = gzip.GzipFile(fileobj=fh)