From afdc56f37cd91c53bc33044894d9f240bfa17996 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 13 Feb 2022 20:01:47 +0200 Subject: [PATCH] Use task active duration for worker task running time --- apiserver/bll/workers/__init__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apiserver/bll/workers/__init__.py b/apiserver/bll/workers/__init__.py index 3ecf6e9..5222be9 100644 --- a/apiserver/bll/workers/__init__.py +++ b/apiserver/bll/workers/__init__.py @@ -258,7 +258,7 @@ class WorkerBLL: tasks_info = { task.id: task for task in Task.objects(id__in=task_ids).only( - "name", "started", "last_iteration" + "name", "started", "last_iteration", "active_duration" ) } @@ -283,11 +283,7 @@ class WorkerBLL: if helper.task_id: task = tasks_info.get(helper.task_id, None) if task: - worker.task.running_time = ( - int((datetime.utcnow() - task.started).total_seconds() * 1000) - if task.started - else 0 - ) + worker.task.running_time = (task.active_duration or 0) * 1000 worker.task.last_iteration = task.last_iteration update_queue_entries(worker.queue)