From 66178acebec6ff7f8d62612a4644f98c9ce5c659 Mon Sep 17 00:00:00 2001 From: Anatoly Bogomolov Date: Fri, 12 Apr 2024 20:17:51 +1000 Subject: [PATCH] task error fix --- app/blueprints/api/tasks/handlers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/blueprints/api/tasks/handlers.py b/app/blueprints/api/tasks/handlers.py index db823d5..b59e395 100644 --- a/app/blueprints/api/tasks/handlers.py +++ b/app/blueprints/api/tasks/handlers.py @@ -4,6 +4,9 @@ from app.models.task import Task def success_state(task_id): task = Task.query.get(task_id) + if not task: + return + task.status = "SUCCESS" task.status_message = "задача выполнена успешно" @@ -12,6 +15,9 @@ def success_state(task_id): def failure_state(task_id, exception): task = Task.query.get(task_id) + if not task: + return + task.status = "FAILURE" task.status_message = f"произошла ошибка {str(exception)}" @@ -20,6 +26,9 @@ def failure_state(task_id, exception): def run_state(task_id, task_record_id): task = Task.query.get(task_record_id) + if not task: + return + task.task_id = task_id task.status = "RUNNING" task.status_message = "задача запущена"