Skip to content

Commit

Permalink
fix: add request timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
boidolr committed May 26, 2024
1 parent d4728a3 commit eea1ea5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion github_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async def query(self, generated_query: str) -> Dict:
"https://api.github.com/graphql",
headers=headers,
json={"query": generated_query},
timeout=30,
)
result = r.json()
if result is not None:
Expand Down Expand Up @@ -106,6 +107,7 @@ async def query_rest(self, path: str, params: Optional[Dict] = None) -> Dict:
f"https://api.github.com/{path}",
headers=headers,
params=tuple(params.items()),
timeout=30,
)
if r.status_code == 202:
print(f"A path returned 202. Retrying...")
Expand Down Expand Up @@ -586,7 +588,8 @@ async def main() -> None:
excluded_langs = os.getenv("EXCLUDED_LANGS")
exclude_langs = set(excluded_langs.split(",")) if excluded_langs else None

async with aiohttp.ClientSession() as session:
timeout = aiohttp.ClientTimeout(total=30)
async with aiohttp.ClientSession(timeout=timeout) as session:
s = Stats(user, access_token, session, exclude_langs=exclude_langs)
print(await s.to_str())

Expand Down

0 comments on commit eea1ea5

Please sign in to comment.