2

I'm running Celery with Django and RabbitMQ and want to see the task states in the database table. Unfortunately no entries are written into the table djcelery_taskstate and I can't figure out why.

My settings:

CELERY_ENABLE_UTC = True
BROKER_URL = "amqp://guest:guest@localhost:5672/"
CELERY_RESULT_BACKEND = "database"
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'

CELERY_TRACK_STARTED = True
CELERY_SEND_EVENTS = True

CELERY_IMPORTS = ("project_management.tasks", "accounting.tasks", "time_tracking.tasks", )
CELERY_ALWAYS_EAGER = False

import djcelery
djcelery.setup_loader()

My Task:

class TestTask(Task):

    def run(self, po_id):
        self.update_state(state=states.STARTED, meta={'total': 0, 'done': False})
        #do something..
        self.update_state(state=states.SUCCESS, meta={'total': 100, 'done': True})

I'm starting the task as follows in a view:

TestTask.apply_async(args=[], kwargs={})

I'm starting celery workers as follows.

python manage.py celeryd -v 1 -B -s celery -E -l INFO

Console gives me the following output:

[2013-05-19 11:10:03,774: INFO/MainProcess] Task accounting.tasks.TestTask[5463b2ed-0eba-451d-b828-7a89fcd36348] succeeded in 0.0538640022278s: None

Any idea what is wrong with my setup?

Thomas Kremmel
  • 14,575
  • 26
  • 108
  • 177

1 Answers1

2

You need to start up the snapshot camera as well in order to see the results in the database.

python manage.py celerycam

Once you have that running, you will be able to see entries in the djcelery tables.

Ngenator
  • 10,909
  • 4
  • 41
  • 46