Last active
March 5, 2024 14:17
-
-
Save emakarov/26557b34671a99d6c29958a84878ec8e to your computer and use it in GitHub Desktop.
celery tasks cleanup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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