stoping state

This commit is contained in:
Анатолий Богомолов 2024-02-03 12:29:56 +00:00
parent da81df4028
commit 5e1f0c1f56
2 changed files with 7 additions and 3 deletions

View File

@ -65,8 +65,13 @@ def stop_task(task_id: int):
if task.task_id: if task.task_id:
task_fn = fn.AsyncResult(task.task_id) task_fn = fn.AsyncResult(task.task_id)
task_fn.abort() task_fn.abort()
task.status = "STOPING"
task.status_message = "Задача останавливается"
return 'Stopped', 200 db.session.commit()
return 'Stoping', 200
@tasks.route("/<int:task_id>/start", methods=["PUT"]) @tasks.route("/<int:task_id>/start", methods=["PUT"])

View File

@ -17,8 +17,7 @@ class Session(db.Model):
def has_depending_tasks(self): def has_depending_tasks(self):
tasks = Task.query \ tasks = Task.query \
.filter_by(session_id=self.id) \ .filter_by(session_id=self.id) \
.filter((Task.status == "RUNNING") | (Task.status == "RUNNING")) \ .filter((Task.status == "RUNNING") | (Task.status == "CREATED") | (Task.status == "STOPING")) \
.all() .all()
return len(tasks) > 0 return len(tasks) > 0