From 5e1f0c1f56f54ee2a3513dc46c17dce8b0603e5e Mon Sep 17 00:00:00 2001 From: winet Date: Sat, 3 Feb 2024 12:29:56 +0000 Subject: [PATCH] stoping state --- app/blueprints/api/tasks/routes.py | 7 ++++++- app/models/session.py | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/blueprints/api/tasks/routes.py b/app/blueprints/api/tasks/routes.py index 3f8a76a..b0f94de 100644 --- a/app/blueprints/api/tasks/routes.py +++ b/app/blueprints/api/tasks/routes.py @@ -65,8 +65,13 @@ def stop_task(task_id: int): if task.task_id: task_fn = fn.AsyncResult(task.task_id) task_fn.abort() + + task.status = "STOPING" + task.status_message = "Задача останавливается" - return 'Stopped', 200 + db.session.commit() + + return 'Stoping', 200 @tasks.route("//start", methods=["PUT"]) diff --git a/app/models/session.py b/app/models/session.py index 3c59e58..9d4707d 100644 --- a/app/models/session.py +++ b/app/models/session.py @@ -17,8 +17,7 @@ class Session(db.Model): def has_depending_tasks(self): tasks = Task.query \ .filter_by(session_id=self.id) \ - .filter((Task.status == "RUNNING") | (Task.status == "RUNNING")) \ + .filter((Task.status == "RUNNING") | (Task.status == "CREATED") | (Task.status == "STOPING")) \ .all() return len(tasks) > 0 - \ No newline at end of file