Skip to content

Commit 375ed71

Browse files
author
Joel Collins
committed
Support View class stop timeout from /tasks resources
1 parent d67f26a commit 375ed71

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/labthings/default_views/tasks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
from ..views import View
55
from ..views.marshalling import marshal_with
6+
from ..views.args import use_args
67
from ..schema import TaskSchema
78
from ..find import current_labthing
9+
from .. import fields
810

911

1012
class TaskList(View):
@@ -46,21 +48,22 @@ def get(self, task_id):
4648

4749
return TaskSchema().dump(task)
4850

49-
def delete(self, task_id):
51+
@use_args({"timeout": fields.Int()})
52+
def delete(self, args, task_id):
5053
"""Terminate a running task.
5154
5255
If the task is finished, deletes its entry.
5356
5457
:param task_id:
5558
5659
"""
57-
60+
timeout = args.get("timeout", None)
5861
task_dict = current_labthing().actions.to_dict()
5962

6063
if task_id not in task_dict:
6164
return abort(404) # 404 Not Found
6265

6366
task = task_dict.get(task_id)
64-
task.stop(timeout=5)
67+
task.stop(timeout=timeout)
6568

6669
return TaskSchema().dump(task)

0 commit comments

Comments
 (0)