Skip to content

gh-134262: increase retries in Tools/build/generate_sbom.py #134558

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

Merged
merged 1 commit into from
May 27, 2025
Merged
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
11 changes: 7 additions & 4 deletions Tools/build/generate_sbom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hashlib
import json
import os
import random
import re
import subprocess
import sys
Expand Down Expand Up @@ -164,16 +165,18 @@ def get_externals() -> list[str]:


def download_with_retries(download_location: str,
max_retries: int = 5,
base_delay: float = 2.0) -> typing.Any:
max_retries: int = 7,
base_delay: float = 2.25,
max_jitter: float = 1.0) -> typing.Any:
"""Download a file with exponential backoff retry."""
for attempt in range(max_retries):
try:
resp = urllib.request.urlopen(download_location)
except urllib.error.URLError as ex:
if attempt == max_retries:
raise ex
time.sleep(base_delay**attempt)
msg = f"Download from {download_location} failed."
raise OSError(msg) from ex
time.sleep(base_delay**attempt + random.uniform(0, max_jitter))
else:
return resp

Expand Down
Loading