简体   繁体   中英

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?

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

Delete the .pyc file for where the task was originally written. Or, just delete all .pyc files in your projects directory.

This command should work:

find . -name "*.pyc" -exec rm -rf {} \;

How do I remove all .pyc files from a project?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM