Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery: selectively clearing queue from Python tasks

Sometimes I have a situation where Celery queue builds up on accidental unnecessary tasks, clogging down the server. E.g. the code shoots up 20 000 tasks instead of 1.

How one can inspect what Python tasks Celery queue contains and then get selectively rid of certain tasks?

Tasks are defined and started with the standard Celery decorators (if that matters):

@task()
def update_foobar(foo, bar):
    # Some heavy activon here
    pass

update_foobar.delay(foo, bar)

Stack: Django + Celery + RabbitMQ.

like image 418
Mikko Ohtamaa Avatar asked Nov 01 '22 05:11

Mikko Ohtamaa


1 Answers

Maybe you can use Flower. It's a real time monitor for Celery with a nice web interface. I think you can shutdown tasks from there. Anyways I would try to avoid those queued unnecessary tasks.

like image 58
Diego Navarro Avatar answered Nov 07 '22 11:11

Diego Navarro