Skip to content

Commit af43fab

Browse files
committed
Merge branch 'develop' into from_pr_commit_github_api
2 parents 8cf1be5 + dbaf194 commit af43fab

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

easybuild/tools/filetools.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ def download_file(filename, url, path, forced=False, trace=True, max_attempts=No
838838
used_urllib = std_urllib
839839
switch_to_requests = False
840840

841+
wait = False
841842
wait_time = initial_wait_time
842843

843844
while not downloaded and attempt_cnt < max_attempts:
@@ -880,6 +881,7 @@ def download_file(filename, url, path, forced=False, trace=True, max_attempts=No
880881
switch_to_requests = True
881882
elif status_code == 429: # too many requests
882883
_log.warning(f"Downloading of {url} failed with HTTP status code 429 (Too many requests)")
884+
wait = True
883885
elif 400 <= status_code <= 499:
884886
_log.warning("URL %s was not found (HTTP response code %s), not trying again" % (url, status_code))
885887
break
@@ -906,10 +908,11 @@ def download_file(filename, url, path, forced=False, trace=True, max_attempts=No
906908
_log.info("Downloading using requests package instead of urllib2")
907909
used_urllib = requests
908910

909-
# exponential backoff
910-
wait_time *= 2
911-
_log.info(f"Waiting for {wait_time} seconds before trying download of {url} again...")
912-
time.sleep(wait_time)
911+
if wait:
912+
_log.info(f"Waiting for {wait_time} seconds before trying download of {url} again...")
913+
time.sleep(wait_time)
914+
# exponential backoff
915+
wait_time *= 2
913916

914917
if downloaded:
915918
_log.info("Successful download of file %s from url %s to path %s" % (filename, url, path))

0 commit comments

Comments
 (0)