Skip to content

Instantly share code, notes, and snippets.

@emakarov
Last active March 5, 2024 14:17
Show Gist options
  • Save emakarov/26557b34671a99d6c29958a84878ec8e to your computer and use it in GitHub Desktop.
Save emakarov/26557b34671a99d6c29958a84878ec8e to your computer and use it in GitHub Desktop.
celery tasks cleanup
from proj.celery import app
from celery.app import control
# remove pending tasks
app.control.purge()
# remove active tasks
i = app.control.inspect()
jobs = i.active()
for hostname in jobs:
tasks = jobs[hostname]
for task in tasks:
app.control.revoke(task['id'], terminate=True)
# remove reserved tasks
jobs = i.reserved()
for hostname in jobs:
tasks = jobs[hostname]
for task in tasks:
app.control.revoke(task['id'], terminate=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment