Skip to content

Commit 168c5d4

Browse files
committed
Increase sleep during possible rate limit errors in downloads
1 parent 7dc92d3 commit 168c5d4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pythonbuild/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,12 @@ def download_to_path(url: str, path: pathlib.Path, size: int, sha256: str):
307307
print(f"HTTP exception on {url}; retrying: {e}")
308308
time.sleep(2**attempt)
309309
except urllib.error.URLError as e:
310-
print(f"urllib error on {url}; retrying: {e}")
311-
time.sleep(2**attempt)
310+
if e.errno in {403, 429}:
311+
print(f"possible rate limit error on {url}; retrying: {e}")
312+
time.sleep(2**(attempt + 2))
313+
else:
314+
print(f"urllib error on {url}; retrying: {e}")
315+
time.sleep(2**attempt)
312316
else:
313317
raise Exception(f"download failed after {attempt} retries: {url}")
314318

0 commit comments

Comments
 (0)