I have a Celery task that takes no argument that runs periodically in the background.
I want to use on_failure
to traceback on the error for the particular object it encounters.
Since it doesn't takes any argument I am not able to assign the value to 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")
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.