简体   繁体   中英

Saving Celery tasks to a Django backend - clearing some confusions

I started working with Celery and integrated it with Django , where I have the latest versions of both.

Celery is configured in settings.py like so:

# Celery settings

BROKER_URL = 'amqp://guest:guest@localhost//'
CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'

#: Only add pickle to this list if your broker is secured
#: from unwanted access (see userguide/security.html)
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'

djcelary is installed.

Now I want to do the following: Store all tasks that have gone through celary in Django's database and have them inspected via django admin

I have done the following in order to achieve that:

  • Run Celary with -E in order to capture events
  • Run python manage.py celarycam

And after this, when I execute tasks, they are added to the database admin.

But here comes my confusion:

  • If I don't run the celarycam from manage.py , nothing is stored (I am looking in the Tasks table in djcelary part of admin) in the admin
  • But If I kill Celary and start it again, and ask for the result with a previous task_id , I get it.

So Celary Django's backend is storing tasks somewhere but unless i turn the celarycam on, I cannot see the tasks in the admin.

What is the right thing to do in order to see all tasks in my Django admin?

Also, can I see tasks that are stored somewhere but weren't captured by celarycam ?

Any comments that can clear my confusion are welcome!

In Celery, Django backend is not supported remote control.

The Django database transport does not currently support:

  • Remote control commands (celery events command, broadcast)
  • Events, including the Django Admin monitor.
  • Using more than a few workers (can lead to messages being executed multiple times).

Django backend is experimental broker . It may be functional but they do not have dedicated maintainers.

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