From 73529bec16cf8c8b7ee31f166366b2da9f4d389a Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Sat, 27 Dec 2025 17:11:14 +0000 Subject: [PATCH] Add timeouts to requests to prevent hanging --- emblem5/ai/fetch-scans.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emblem5/ai/fetch-scans.py b/emblem5/ai/fetch-scans.py index 9799431..8e1d800 100755 --- a/emblem5/ai/fetch-scans.py +++ b/emblem5/ai/fetch-scans.py @@ -48,7 +48,7 @@ class ScanDataFetcher(object): local_scan_data = self.load_local_scan_data() logger.info(f'local_scan_data: {len(local_scan_data)}') url = 'https://themblem.com/api/v1/scan-data-labels/' - r = requests.get(url, headers=self.make_headers()) + r = requests.get(url, headers=self.make_headers(), timeout=30) data = r.json() fetch_backlog = [] scan_ids_set = set(scan_ids) if scan_ids else None @@ -104,7 +104,7 @@ class ScanDataFetcher(object): frame_img_url = f'https://themblem.com/api/v1/oss-image/?token={self.token}&name={quote(scan["image"])}' frame_img_file = os.path.join(scan_dir, 'frame.jpg') if not os.path.exists(frame_img_file): - r = requests.get(frame_img_url) + r = requests.get(frame_img_url, timeout=30) r.raise_for_status() # Raise an exception for bad status codes with open(frame_img_file, 'wb') as f: f.write(r.content)