Skip to content

Commit 0525851

Browse files
committed
Use Stamina to avoid 502: Bad Gateway
1 parent c09da4c commit 0525851

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

orphaned_backports.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# dependencies = [
1010
# "ghapi",
1111
# "rich",
12+
# "stamina",
1213
# ]
1314
# ///
1415

@@ -18,8 +19,10 @@
1819
import datetime as dt
1920
import json
2021
import os
22+
import urllib
2123
from typing import Any, TypeAlias
2224

25+
import stamina
2326
from fastcore.xtras import obj2dict
2427
from ghapi.all import GhApi, paged # pip install ghapi
2528
from rich import print # pip install rich
@@ -70,6 +73,11 @@ def is_linked_issue_closed(api: GhApi, pr: PR) -> bool:
7073
return issue["state"] == "closed"
7174

7275

76+
@stamina.retry(on=urllib.error.HTTPError)
77+
def stamina_paged(*args, **kwargs):
78+
return paged(*args, **kwargs)
79+
80+
7381
def check_prs(
7482
start: int = 1,
7583
number: int = 100,
@@ -82,7 +90,8 @@ def check_prs(
8290

8391
candidates = []
8492
pr_count = 0
85-
for page in paged(
93+
94+
for page in stamina_paged(
8695
api.pulls.list,
8796
state="open",
8897
creator=author,

0 commit comments

Comments
 (0)