88import signal
99import socket
1010import tempfile
11- import random
1211import time
1312import uuid
1413import requests
@@ -504,10 +503,10 @@ def __init__(self, run_args):
504503 self .requests_session = requests .Session ()
505504 adapter = requests .adapters .HTTPAdapter (
506505 max_retries = Retry (
507- total = 5 ,
508- backoff_factor = 2 ,
506+ total = 3 ,
507+ backoff_factor = 1 ,
509508 status_forcelist = [502 , 503 , 504 ],
510- allowed_methods = ["PATCH" , "GET" , "PUT" , "POST" ],
509+ allowed_methods = ["PATCH" , "GET" , "PUT" ],
511510 )
512511 )
513512 self .requests_session .mount ("http://" , adapter )
@@ -617,36 +616,20 @@ def _get_stdout_stderr_file_names(self, run_args):
617616 ]
618617 return [run_args [name ] for name in DETAILED_OUTPUT_NAMES ]
619618
620- def _update_submission (self , data , max_retries = 5 , backoff_base = 2 ):
619+ def _update_submission (self , data ):
621620 url = f"{ self .submissions_api_url } /submissions/{ self .submission_id } /"
622621 data ["secret" ] = self .secret
623622
624- for attempt in range (1 , max_retries + 1 ):
625- logger .info (f"Updating submission @ { url } (attempt { attempt } /{ max_retries } ) with data = { data } " )
626- try :
627- resp = self .requests_session .patch (url , data = data , timeout = 150 )
628- except requests .exceptions .RequestException as exc :
629- logger .warning (f"Submission patch request failed (attempt { attempt } /{ max_retries } ): { exc } " )
630- if attempt == max_retries :
631- raise SubmissionException (f"Failure updating submission data after { max_retries } attempts." )
632- sleep_s = backoff_base ** attempt + random .uniform (0 , 1 )
633- logger .info (f"Retrying in { sleep_s :.1f} s..." )
634- time .sleep (sleep_s )
635- continue
636-
637- if resp .status_code == 200 :
638- logger .info ("Submission updated successfully!" )
639- return
640- else :
641- logger .warning (
642- f"Submission patch failed (attempt { attempt } /{ max_retries } ) "
643- f"with status = { resp .status_code } , and response = \n { resp .content } "
644- )
645- if attempt == max_retries :
646- raise SubmissionException (f"Failure updating submission data after { max_retries } attempts." )
647- sleep_s = backoff_base ** attempt + random .uniform (0 , 1 )
648- logger .info (f"Retrying in { sleep_s :.1f} s..." )
649- time .sleep (sleep_s )
623+ logger .info (f"Updating submission @ { url } " )
624+
625+ resp = self .requests_session .patch (url , data = data , timeout = 150 )
626+ if resp .status_code == 200 :
627+ logger .info ("Submission updated successfully!" )
628+ else :
629+ logger .error (
630+ f"Submission patch failed with status = { resp .status_code } , and response = \n { resp .content } "
631+ )
632+ raise SubmissionException ("Failure updating submission data." )
650633
651634 def _update_status (self , status , extra_information = None ):
652635 # Update submission status
@@ -658,6 +641,7 @@ def _update_status(self, status, extra_information=None):
658641 try :
659642 self ._update_submission (data )
660643 except Exception as e :
644+ # Re-raise only for terminal statuses so Celery marks the task as failed.
661645 logger .exception (f"Failed to update submission status to { status } : { e } " )
662646 if status in ("Finished" , "Failed" ):
663647 raise
0 commit comments