Saturday, August 23, 2014

Why the Celery task was not executed in my Django app

Yesterday, after deploying my Django apps stack to a new Ubuntu server (14.04 from 12.04), I found that the Celery task was not executed. What happened?

Finally, I managed to make it work again following these changes:

1. Upgrade these python modules to the latest version (come with Ubuntu 14.04): Django 1.6.6, django-celery 3.1.10, celery 3.1.13librabbitmq 1.5.2 (to avoid warning about rabbitmq compatibility)

2. Add these CELERY settings (in red color) in my Django app's settings.py:

...
CELERY_IMPORTS = ("myapp.tasks",)
CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'
CELERY_ACCEPT_CONTENT = ['pickle', 'json'] # new in celery 3.1
CELERY_TRACK_STARTED = True
...

(remember to restart the celery beat after making those changes)