diff --git a/potential_closeable_issues.py b/potential_closeable_issues.py index c151ef8..a59578a 100644 --- a/potential_closeable_issues.py +++ b/potential_closeable_issues.py @@ -8,6 +8,7 @@ # dependencies = [ # "ghapi", # "rich", +# "stamina", # ] # /// @@ -18,7 +19,9 @@ import json import os from typing import Any, TypeAlias +from urllib.error import HTTPError +import stamina from fastcore.net import HTTP404NotFoundError from fastcore.xtras import obj2dict from ghapi.all import GhApi, paged # pip install ghapi @@ -68,7 +71,9 @@ def check_issue(api: GhApi, issue: Issue) -> list[Issue]: word = next(word for word in pr_line.split() if word.startswith("gh-")) pr_number = int(word.split("-")[1]) try: - pr = api.pulls.get(pr_number) + for attempt in stamina.retry_context(on=HTTPError): + with attempt: + pr = api.pulls.get(pr_number) except HTTP404NotFoundError as e: print(f"[yellow]PR {pr_number} not found: {e}[/yellow]") continue diff --git a/requirements.txt b/requirements.txt index 099573b..225e093 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,5 @@ pytest pytest-cov requests rich +stamina termcolor