Search code examples
djangocelerydjango-celery

Django, Celery, RabbitMQ - Tasks are not been executed


I have setup my Django env like this:

INSTALLED_APPS = (
....
    'djcelery',

)

BROKER_URL = "amqp://guest:guest@localhost:5672//"
CELERY_IMPORTS = ('bulksms.tasks', 'premiumsms.tasks', 'reports.tasks')
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"

import djcelery
djcelery.setup_loader()

In the Django admin I add the task I want to periodic tasks (I can see all the tasks there) to run every minute for testing purposes but the task never runs.

Running django then 
python manage.py celeryd -E --loglevel=DEBUG
python manage.py celerycam

In the admin site under Djcelery there is also no option for Tasks to ADD (not sure if it used to be there.)


Solution

  • If you want to run periodic tasks with Celery then you need to run the celerybeat process with either

    python manage.py celery beat
    

    or using another thread in the worker process

    python manage.py celery worker -E --loglevel=DEBUG -B
    

    See the docs on starting the scheduler http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html#starting-the-scheduler