Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery beat queue includes obsolete tasks

I'm using periodic celery tasks with Django. I used to have the following task in my app/tasks.py file:

@periodic_task(run_every=timedelta(minutes=2))
def stuff():
  ...

But now this task has been removed from my app/tasks.py file. However, I keep seeing call to this task in my celery logs:

[2013-05-21 07:08:37,963: ERROR/MainProcess] Received unregistered task of type u'app.tasks.stuff'.

It seems that the celery beat scheduler that I use does not update its queue. This is how the scheduler is defined in my project/settings.py file:

CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"

Restarting the celery worker does not help. FYI, I use a Redis broker.

How can I either clear or update the celery beat queue so that older tasks are not sent to my celery worker?

like image 345
Régis B. Avatar asked May 21 '13 12:05

Régis B.


People also ask

Why use Celery with Django?

Celery makes it easier to implement the task queues for many workers in a Django application.

Is Celery async?

Celery tasks run asynchronously, which means that the Celery function call in the calling process returns immediately after the message request to perform the task is sent to the broker. There are two ways to get results back from your tasks.

What is Celery in message queue?

Celery is an open source asynchronous task queue or job queue which is based on distributed message passing. While it supports scheduling, its focus is on operations in real time. Celery. Stable release. 5.2.3 / December 29, 2021.

What is the use of Celery in Python?

Celery is a distributed task queue for UNIX systems. It allows you to offload work from your Python app. Once you integrate Celery into your app, you can send time-intensive tasks to Celery's task queue.


1 Answers

Install django-celery.

As cited, this project is not needed to use celery but yet you need this to enable the admin interface at /admin/djcelery/ for managing periodic tasks. Initially there won't be no registered or periodic tasks.

Restart the beat and check the table Periodic tasks again. Beat would have added the existing scheduled tasks into that table with the interval or crontab defined in the settings or the decorators. There you can delete the unwanted tasks.

UPDATE: From celery4, it's recommended to use this package. https://github.com/celery/django-celery-beat

like image 99
Babu Avatar answered Sep 22 '22 00:09

Babu