Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134262: Add retries to generate_sbom.py#134263

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 6 commits intopython:mainfromemmatyping:retry-generate-sbom-dl
May 21, 2025
Merged
Changes fromall 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
19 changes: 18 additions & 1 deletionTools/build/generate_sbom.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,9 @@
import re
import subprocess
import sys
import time
import typing
import urllib.error
import urllib.request
from pathlib import Path, PurePosixPath, PureWindowsPath

Expand DownExpand Up@@ -161,6 +163,21 @@ def get_externals() -> list[str]:
return externals


def download_with_retries(download_location: str,
max_retries: int = 5,
base_delay: float = 2.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)
else:
return resp


def check_sbom_packages(sbom_data: dict[str, typing.Any]) -> None:
"""Make a bunch of assertions about the SBOM package data to ensure it's consistent."""

Expand All@@ -175,7 +192,7 @@ def check_sbom_packages(sbom_data: dict[str, typing.Any]) -> None:
# and that the download URL is valid.
if "checksums" not in package or "CI" in os.environ:
download_location = package["downloadLocation"]
resp =urllib.request.urlopen(download_location)
resp =download_with_retries(download_location)
error_if(resp.status != 200, f"Couldn't access URL: {download_location}'")

package["checksums"] = [{
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp