英文:
celery postgres backend not storing number of retries
问题
- 失败的任务如预期地重试
- PostgreSQL 后端未存储失败任务的重试次数
- Celery Flower API 正确返回重试次数
测试
以下返回None
,
AsyncResult(task_id='some_taskid', app=app).retries
select task_id, status, retries from celery_taskmeta where retries > 0;
希望对您有所帮助!
英文:
Context
- failed tasks retry as expected
- postgresql backend is not storing number of retries for failed tasks
- celert flower api correctly returns number of retries
Tests
These return None
,
AsyncResult(task_id='some_taskid', app=app).retries
select task_id, status, retries from celery_taskmeta where retries > 0;
Any feedback would be super helpful!
答案1
得分: 1
Before answering the question, I assume that you use celery 5.0+ version.
根据您的上下文和测试,我猜测您可能没有在celery配置中设置result_extended=True
。
如果在celery中设置了这个配置,您的结果后端postgresql将记录扩展结果,如重试、队列等等。
官方配置文档有解释。
为什么您可以从flower API获取retries
,而无法从您的测试方式获取重试?
因为celery中有两个模块可以获取任务的重试次数。
一个是celery.result
模块,用于从结果后端获取任务结果,另一个是celery.event
模块,用于实时任务监视和任务事件消息。
Flower API使用celery.event
模块来捕获您的任务事件。如果您没有设置上述配置,结果后端中就不会有扩展结果项。
英文:
Before answering the question, I assume that you use celery 5.0+ version.
According to your context and test, I guess you may not set up result_extended=True
in celery config.
If you set this config in celery, your result backend postgresql will record extend result such as retries, queue.... etc.
There is official config document explaination.
Why you can fetch retries
from flower API and you can't fetch retries from your test way?
Because there are two module in celery which can fetch the retries count of the task.
One is celery.result
module for fetch task result with result backend and the other one is celery.event
module for real-time task monitor with task event message.
Flower API use celery.event
module to capture your task event. And you don't set the above config, there is not extend result item in the result backend.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论