[英]Django-Celery Periodic tasks error handling
I have a Celery task that takes no argument that runs periodically in the background. 我有一个Celery任务,该任务没有在后台定期运行的参数。
I want to use on_failure
to traceback on the error for the particular object it encounters. 我想使用
on_failure
追溯其遇到的特定对象的错误。
Since it doesn't takes any argument I am not able to assign the value to args
. 由于它不需要任何参数,因此我无法将值分配给
args
。
How should I get the object and the error it encounters while the task is getting executed? 我应该如何获取对象及其在执行任务时遇到的错误?
I guess this piece of code is working 我猜这段代码正在工作
from celery.task import PeriodicTask
class Task(PeriodicTask):
run_every = crontab(minute=0, hour=0)
def run(self, **kwargs):
# to do
def on_failure(self, exc, task_id, args, kwargs, einfo):
print("Failed")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.