Skip to content

Increase sleep during possible rate limit errors in downloads #565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pythonbuild/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,14 @@ def download_to_path(url: str, path: pathlib.Path, size: int, sha256: str):
print(f"HTTP exception on {url}; retrying: {e}")
time.sleep(2**attempt)
except urllib.error.URLError as e:
print(f"urllib error on {url}; retrying: {e}")
time.sleep(2**attempt)
if e.errno in {403, 429}:
print(f"possible rate limit error on {url}; retrying: {e}")
time.sleep(2 ** (attempt + 2))
else:
print(f"urllib error on {url}; retrying: {e}")
time.sleep(2**attempt)
else:
raise Exception("download failed after multiple retries: %s" % url)
raise Exception(f"download failed after {attempt} retries: {url}")

tmp.rename(path)
print("successfully downloaded %s" % url)
Expand Down
Loading