What are the django-celery (djcelery) tables for?

2019-04-04 04:45发布

问题:

When I run syncdb, I notice a lot of tables created like:

  • djcelery_crontabschedule
  • ...
  • djcelery_taskstate

django-kombu is providing the transport, so it can't be related to the actual queue. Even when I run tasks, I still see nothing populated in these tables. What are these tables used for? Monitoring purposes only -- if I enable it?

If so, is it also true that if I do a lookup of AsyncResult(), I'm guessing that is actually looking up the task result via the django-kombu tables instead of djcelery?

Thanks.

回答1:

The celery task_state table, populated by the daemon celerycam, is just for monitoring purposes.

The other tables, like "crontabschedule" "intervals" etc. are for scheduling periodic tasks by using the django backend db. These tables are used when you launch celery in beat mode (-B) and when you have this var set in the settings

CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"

In this way you tell celery to use the django db for schedule tasks.