@@ -236,7 +236,12 @@ def query_CCDBTimeMachineTS(base_url, user, period, passname):
236236
237237 print_info (f"Checking if CCDBTimeMachineTS already exists: { url } " )
238238
239- response = requests .get (url , cert = (cert_path , key_path ), verify = False )
239+ try :
240+ response = requests .get (url , cert = (cert_path , key_path ), verify = False , timeout = 15 )
241+ except (requests .RequestException , OSError ) as exc :
242+ print_warning (f"CCDB query failed with { type (exc ).__name__ } : { exc } " )
243+ return None , False
244+
240245 if response .status_code == 200 :
241246 meta = extract_metadata_blocks_from_CCDB (response .content .decode ('utf-8' ))
242247 if (len (meta ) > 0 ):
@@ -278,14 +283,18 @@ def upload_CCDBTimeMachineTS(base_url, user, keys):
278283 print_info (f"Uploading CCDBTimeMachineTS: { url } " )
279284
280285 # Prepare request
281- with open (empty_file , 'rb' ) as f :
282- files = {'blob' : f }
283- response = requests .post (url , files = files , cert = (cert_path , key_path ), verify = False )
284-
285- os .remove (empty_file )
286+ try :
287+ with open (empty_file , 'rb' ) as f :
288+ files = {'blob' : f }
289+ response = requests .post (url , files = files , cert = (cert_path , key_path ), verify = False , timeout = 15 )
290+ except (requests .RequestException , OSError ) as exc :
291+ print_warning (f"CCDB upload failed with { type (exc ).__name__ } : { exc } " )
292+ return
293+ finally :
294+ os .remove (empty_file )
286295
287296 if response .status_code != 201 :
288- print_warning (f"Upload failed, response: { response .status_code } " )
297+ print_warning (f"CCDB upload failed, response: { response .status_code } " )
289298
290299
291300def get_CCDBTimeMachineTS (production_tag , year , period , run , passname ,
0 commit comments