Skip to content

Commit f96444b

Browse files
committed
ci: Create constants for retry mechanism variables
1 parent de2376c commit f96444b

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

dependencies/scripts/download_packages.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@
1818
datefmt="%Y-%m-%d %H:%M:%S",
1919
)
2020

21-
21+
# Directory name
2222
DEPENDENCIES_DIR = "dependencies"
23+
24+
# Sources
2325
TOP_PYPI_SOURCE = "https://hugovk.github.io/top-pypi-packages/top-pypi-packages.min.json"
2426
TOP_NPM_SOURCE = "https://packages.ecosyste.ms/api/v1/registries/npmjs.org/packages"
27+
28+
# Retry configuration constants
29+
RETRY_ATTEMPTS = 10
30+
RETRY_WAIT_JITTER = 1
31+
RETRY_WAIT_EXP_BASE = 2
32+
RETRY_WAIT_MAX = 8
2533
TIMEOUT = 90
2634

2735

@@ -95,10 +103,10 @@ def download(
95103

96104
@stamina.retry(
97105
on=(httpx.TransportError, httpx.TimeoutException, ServerError),
98-
attempts=10,
99-
wait_jitter=1,
100-
wait_exp_base=2,
101-
wait_max=8,
106+
attempts=RETRY_ATTEMPTS,
107+
wait_jitter=RETRY_WAIT_JITTER,
108+
wait_exp_base=RETRY_WAIT_EXP_BASE,
109+
wait_max=RETRY_WAIT_MAX,
102110
)
103111
def get_packages(
104112
base_url: str, parser: Callable[[dict[str, Any]], set[str]], params: dict[str, Any] | None = None

0 commit comments

Comments
 (0)