@@ -189,6 +189,7 @@ def dispatch(self, uuid, user, documents, query, parameters, event_id):
189189 f"{ self .api_url } /dispatches" ,
190190 headers = self .api_headers ,
191191 json = {"event_type" : self .name , "client_payload" : payload },
192+ timeout = 10
192193 )
193194 resp .raise_for_status ()
194195
@@ -197,6 +198,7 @@ def update_config(self):
197198 resp = requests .get (
198199 f"{ self .api_url } /contents/config.yaml" ,
199200 headers = {** self .api_headers , "Accept" : "application/vnd.github.v3.raw" },
201+ timeout = 10
200202 )
201203 if resp .status_code == 404 :
202204 self .error = True
@@ -380,7 +382,7 @@ def find_run_id(self):
380382 url = f"{ self .addon .api_url } /actions/runs?created=%3E{ date_filter } "
381383 while url is not None :
382384 logger .info ("[FIND RUN ID] get %s" , url )
383- resp = requests .get (url , headers = self .addon .api_headers )
385+ resp = requests .get (url , headers = self .addon .api_headers , timeout = 10 )
384386 resp .raise_for_status ()
385387 url = resp .links .get ("next" , {}).get ("url" )
386388 resp_json = resp .json ()
@@ -403,7 +405,11 @@ def find_run_id(self):
403405 else :
404406 continue
405407
406- resp = requests .get (jobs_url , headers = self .addon .api_headers )
408+ resp = requests .get (
409+ jobs_url ,
410+ headers = self .addon .api_headers ,
411+ timeout = 10
412+ )
407413 resp .raise_for_status ()
408414
409415 jobs = resp .json ()["jobs" ]
@@ -435,6 +441,7 @@ def set_status(self):
435441 resp = requests .get (
436442 f"{ self .addon .api_url } /actions/runs/{ self .run_id } " ,
437443 headers = self .addon .api_headers ,
444+ timeout = 10
438445 )
439446 if resp .status_code != 200 :
440447 logger .info (
@@ -449,7 +456,9 @@ def set_status(self):
449456 # if we failed, check the job status to check for 'cancelled'
450457 # which means it timed out
451458 resp = requests .get (
452- resp .json ()["jobs_url" ], headers = self .addon .api_headers
459+ resp .json ()["jobs_url" ],
460+ headers = self .addon .api_headers ,
461+ timeout = 10
453462 )
454463 if resp .status_code == 200 and len (resp .json ()["jobs" ]) > 0 :
455464 status = resp .json ()["jobs" ][0 ]["conclusion" ]
@@ -510,6 +519,7 @@ def cancel(self):
510519 resp = requests .post (
511520 f"{ self .addon .api_url } /actions/runs/{ self .run_id } /cancel" ,
512521 headers = self .addon .api_headers ,
522+ timeout = 10
513523 )
514524 if resp .status_code == 202 :
515525 return "succeed"
@@ -718,6 +728,7 @@ def token(self):
718728 "https://api.github.com/app/installations/"
719729 f"{ self .iid } /access_tokens" ,
720730 headers = headers ,
731+ timeout = 10
721732 )
722733 resp = resp .json ()
723734 token = resp ["token" ]
0 commit comments