From c25011d92d4647dff803e255fdd5d11b215fdf0c Mon Sep 17 00:00:00 2001 From: carmichaelong Date: Mon, 28 Oct 2024 17:13:04 -0700 Subject: [PATCH] always try to post duration --- app.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index e82ab7f3..7a636cf7 100644 --- a/app.py +++ b/app.py @@ -147,16 +147,13 @@ # trigger reset of timer for last processed trial processTrial(trial["session"], trial["id"], trial_type=trial_type, isDocker=isDocker) - # End process duration timer and post duration to database - process_end_time = datetime.now() - postProcessedDuration(trial_url, process_end_time - process_start_time) - # note a result needs to be posted for the API to know we finished, but we are posting them # automatically thru procesTrial now r = requests.patch(trial_url, data={"status": "done"}, headers = {"Authorization": "Token {}".format(API_TOKEN)}) logging.info('0.5s pause if need to restart.') time.sleep(0.5) + except Exception as e: r = requests.patch(trial_url, data={"status": "error"}, headers = {"Authorization": "Token {}".format(API_TOKEN)}) @@ -172,6 +169,12 @@ # message = "A backend OpenCap machine timed out during pose detection. It has been stopped." # sendStatusEmail(message=message) # raise Exception('Worker failed. Stopped.') + + finally: + # End process duration timer and post duration to database + process_end_time = datetime.now() + postProcessedDuration(trial_url, process_end_time - process_start_time) + justProcessed = True # Clean data directory