From 0b0fa48369d8b66353005a66db26ef30316be3a3 Mon Sep 17 00:00:00 2001 From: Pranjal Jha <136667416+pranjal2004838@users.noreply.github.com> Date: Mon, 18 May 2026 08:17:35 +0000 Subject: [PATCH] Fix: Add timeout to requests.get in network fetch scripts to prevent infinite hangs --- scripts/1-fetch/github_fetch.py | 2 +- scripts/1-fetch/smithsonian_fetch.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/1-fetch/github_fetch.py b/scripts/1-fetch/github_fetch.py index 395166a6..baff37a9 100755 --- a/scripts/1-fetch/github_fetch.py +++ b/scripts/1-fetch/github_fetch.py @@ -95,7 +95,7 @@ def query_github(args, session): request_url = f"{base_url}{search_parameters}" try: - with session.get(request_url) as response: + with session.get(request_url, timeout=30) as response: response.raise_for_status() search_data = response.json() count = search_data["total_count"] diff --git a/scripts/1-fetch/smithsonian_fetch.py b/scripts/1-fetch/smithsonian_fetch.py index ab44e320..cf6f4228 100755 --- a/scripts/1-fetch/smithsonian_fetch.py +++ b/scripts/1-fetch/smithsonian_fetch.py @@ -114,7 +114,7 @@ def query_smithsonian(args, session): url = "https://api.si.edu/openaccess/api/v1.0/stats" params = {"api_key": DATA_GOV_API_KEY} try: - with session.get(url, params=params) as response: + with session.get(url, params=params, timeout=30) as response: response.raise_for_status() data = response.json()["response"] except requests.HTTPError as e: