https://github.com/python/cpython/commit/751a890f160cfc2b810d093aed7570fb98e2de62
commit: 751a890f160cfc2b810d093aed7570fb98e2de62
branch: 3.13
author: Emma Smith <[email protected]>
committer: hugovk <[email protected]>
date: 2025-08-07T07:17:28+03:00
summary:
[3.13] gh-134262: increase retries in `Tools/build/generate_sbom.py` … (#137496)
[3.13] gh-134262: increase retries in `Tools/build/generate_sbom.py` (GH-134558)
(cherry picked from commit 3f9eb55e090a8de80503e565f508f341c5f4c8da)
files:
M Tools/build/generate_sbom.py
diff --git a/Tools/build/generate_sbom.py b/Tools/build/generate_sbom.py
index 450d163fd3b7a6..82f06f0a7e57f9 100644
--- a/Tools/build/generate_sbom.py
+++ b/Tools/build/generate_sbom.py
@@ -1,5 +1,6 @@
"""Tool for generating Software Bill of Materials (SBOM) for Python's
dependencies"""
import os
+import random
import re
import hashlib
import json
@@ -167,16 +168,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
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]