Celery task history

2019-05-02 09:42发布

I am building a framework for executing tasks on top of Celery framework.

I would like to see the list of recently executed tasks (for the recent 2-7 days).

Looking on the API I can find app.backend object, but cannot figure out how to make a query to fetch tasks.

For example I can use backends like Redis or database. I do not want to explicitly write SQL queries to database.

Is there a way to work with task history/results with API?

I tried to use Flower, but it can only handle events and cannot get history before its start.

2条回答
再贱就再见
2楼-- · 2019-05-02 09:59

You can use the persisent option,eg: flower -A ctq.celery --persistent=True

查看更多
神经病院院长
3楼-- · 2019-05-02 10:19

You need to keep the task results in a backend, for example Redis. The Celery documentation contains information about how to do this here:

http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#keeping-results

Also you want to set the CELERY_TASK_RESULT_EXPIRES configuration parameter, because by default the results are discarded after one day.

If you do this, then Flower will show you the history of the task execution, irregardless from when it started.

查看更多
登录 后发表回答