TaskManager.py
531 Bytes
from pyrosapp.models import *
from celery.task.control import revoke
def delete_pending_tasks(task_names):
'''
Deletes the pending tasks given in task_names, getting their ids in DB.
Removes them from db.
:param task_names: array of tasks names to delete
'''
for task_name in task_names:
tasks = TaskId.objects.filter(task=task_name)
for task in tasks:
print("je revoke : ", task.task_id)
revoke(task.task_id, terminate=True)
task.delete()