uncloud-mravi/uncloud/tasks.py

15 lines
369 B
Python
Raw Normal View History

from celery import shared_task
from celery.result import AsyncResult
from .models import UncloudTask
@shared_task
def cleanup_tasks():
print("Cleanup time")
for task in UncloudTask.objects.all():
print(f"Pruning {task}...")
res = AsyncResult(id=str(task.task_id))
if res.ready():
print(res.get())
task.delete()