Add timeouts to requests to prevent hanging
This commit is contained in:
parent
59425ca9fb
commit
73529bec16
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user