Skip to content

Commit

Permalink
Fix restart/delete tasks action (#76)
Browse files Browse the repository at this point in the history
* Replace restart_tasks and delete_tasks methods with the relative KartonBackend methods

* Revert cancel refactor

---------

Co-authored-by: Michał Praszmo <[email protected]>
  • Loading branch information
Antelox and nazywam authored Jun 20, 2023
1 parent 9d55d8b commit 00c788e
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions karton/dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
request,
send_from_directory,
)
from karton.core import Producer
from karton.core.backend import KartonMetrics
from karton.core.base import KartonBase
from karton.core.inspect import KartonAnalysis, KartonQueue, KartonState
Expand Down Expand Up @@ -51,16 +50,6 @@ class KartonDashboard(KartonBase):
)


def restart_tasks(tasks: List[Task]) -> None:
identity = "karton.dashboard-retry"
producer = Producer(identity=identity)

for task in tasks:
# spawn a new task and mark the original one as finished
producer.send_task(task.fork_task())
karton.backend.set_task_status(task=task, status=TaskState.FINISHED)


def cancel_tasks(tasks: List[Task]) -> None:
for task in tasks:
karton.backend.set_task_status(task=task, status=TaskState.FINISHED)
Expand Down Expand Up @@ -280,7 +269,8 @@ def restart_crashed_queue_tasks(queue_name):
if not queue:
return jsonify({"error": "Queue doesn't exist"}), 404

restart_tasks(queue.crashed_tasks)
for task in queue.crashed_tasks:
karton.backend.restart_task(task)
return redirect(request.referrer)


Expand Down Expand Up @@ -312,7 +302,7 @@ def restart_task(task_id):
if not task:
return jsonify({"error": "Task doesn't exist"}), 404

restart_tasks([task])
karton.backend.restart_task(task)
return redirect(request.referrer)


Expand Down

0 comments on commit 00c788e

Please sign in to comment.