diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-31 17:38:13 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-03-31 17:38:13 +0300 |
commit | fe72c7e5c400a7e2cab87536cac8f26fb55f0cea (patch) | |
tree | 96543eaa3e21e34597a34ba4e7d661ef1daeb308 /project/boost/download.py | |
parent | Makefile: more explicit requirements (diff) | |
download | cmake-common-fe72c7e5c400a7e2cab87536cac8f26fb55f0cea.tar.gz cmake-common-fe72c7e5c400a7e2cab87536cac8f26fb55f0cea.zip |
project.boost: retry downloads
Diffstat (limited to 'project/boost/download.py')
-rw-r--r-- | project/boost/download.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/project/boost/download.py b/project/boost/download.py index ae18e94..13a89f4 100644 --- a/project/boost/download.py +++ b/project/boost/download.py @@ -25,14 +25,19 @@ import urllib.request from project.boost.archive import Archive, PermanentStorage, TemporaryStorage from project.boost.version import Version -from project.utils import normalize_path, setup_logging +from project.utils import normalize_path, retry, setup_logging + + +@retry(urllib.request.URLError) +def _download_try_url_retry(url): + with urllib.request.urlopen(url, timeout=20) as request: + return request.read() def _download_try_url(url): logging.info('Trying URL: %s', url) try: - with urllib.request.urlopen(url, timeout=20) as request: - return request.read() + return _download_try_url_retry(url) except urllib.request.URLError as e: logging.error("Couldn't download from this mirror, an error occured:") logging.exception(e) |