pygithub: try to retry requests

We get a lot of errors recently
This commit is contained in:
Christoph Reiter 2021-04-11 14:37:57 +02:00
parent 251a70c6d0
commit 79ab25aa7d
2 changed files with 4 additions and 0 deletions

2
.mypy.ini Normal file
View File

@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True

View File

@ -19,6 +19,7 @@ import traceback
from tabulate import tabulate
from concurrent.futures import ThreadPoolExecutor
from contextlib import contextmanager
from urllib3.util import Retry
import requests
import shlex
import time
@ -1135,6 +1136,7 @@ def get_github(optional_credentials: bool = False) -> Github:
has_creds = bool(kwargs)
# 100 is the maximum allowed
kwargs['per_page'] = 100
kwargs['retry'] = Retry(total=3, backoff_factor=1)
gh = Github(**kwargs)
if not has_creds and optional_credentials:
print(f"[Warning] Rate limit status: {gh.get_rate_limit().core}", file=sys.stderr)