Celery Storing unrecoverable task failures for later resubmission

妖精的绣舞 提交于 2019-12-05 16:45:00

You can probably access old jobs using:

CELERY_RESULT_BACKEND = "database"

and in your code:

from djcelery.models import TaskMeta
task = TaskMeta.objects.filter(task_id='af3185c9-4174-4bca-0101-860ce6621234')[0]

but I'm not sure you can find the arguments that the task is being started with ... Maybe something with TaskState...

I've never used it this way. But you might want to consider the task.retry feature? An example from celery docs:

@task()
def task(*args):
    try:
        some_work()
    except SomeException, exc:
        # Retry in 24 hours.
        raise task.retry(*args, countdown=60 * 60 * 24, exc=exc)
dpn

From IRC

<asksol> dpn`: task args and kwargs are not stored with the result

<asksol> dpn`: but you can create your own model and store it there (for example using the task_sent signal)

<asksol> we don't store anything when the task is sent, only send a message. but it's very easy to do yourself

This was what I was expecting, but hoped to avoid.

At least I have an answer now :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!