Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restart/delete tasks action #76

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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