From 68b84a2b07de2abac07127a393e199a401fcff9f Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Tue, 21 Sep 2021 13:45:45 +1000 Subject: [PATCH] prevent div by zero error, when job is > 5 minutes, and no progress yet --- job.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/job.py b/job.py index fc2d585..98b2443 100644 --- a/job.py +++ b/job.py @@ -135,7 +135,8 @@ def joblog(id): duration= duration-timedelta(microseconds=duration.microseconds) estimate=None duration_s = duration.total_seconds() - if duration_s > 300 and joblog.pa_job_state != "Completed": + # if job is old, not completed, and we have num_files and current_file_num > 0 so we can work out an estimated duration + if duration_s > 300 and joblog.pa_job_state != "Completed" and joblog.current_file_num and joblog.num_files: estimate_s = duration_s / joblog.current_file_num * joblog.num_files estimate = timedelta( seconds=(estimate_s-duration_s) ) estimate = estimate - timedelta(microseconds=estimate.microseconds)