prevent div by zero error, when job is > 5 minutes, and no progress yet

This commit is contained in:
2021-09-21 13:45:45 +10:00
parent 9f90cdaaac
commit 68b84a2b07

3
job.py
View File

@@ -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)