What is the signature of the celery `on_error` handler and how do I pass arguments to it?

Viewed 501

I saw this question which was unanswered: Pass parameters to Celery on_error task

My first question is, what is the signature of the error handler we can pass to a Celery task using on_error(...) or apply(..., link_error=...).

In the link above (pass Pass parameters to Celery on_error task, their on_error has signature:

multiple.on_failure(exc, task_id, args, kwargs, einfo)

In this link from the docs about Canvas , the signature is:

@app.task
def log_error(request, exc, traceback):
    with open(os.path.join('/var/errors', request.id), 'a') as fh:
        print('--\n\n{0} {1} {2}'.format(task_id, exc, traceback), file=fh)

In this other link from the docs: Calling Tasks, the signature is:

@app.task
def error_handler(uuid):
    result = AsyncResult(uuid)
    exc = result.get(propagate=False)
    print('Task {0} raised exception: {1!r}\n{2!r}'.format(uuid, exc, result.traceback))

In my own codebase, I see people using:

def handle_error(*args, **kwargs):

In addition, can you set a breakpoint using rdb inside of an on_error handler? Also why does the handler have to be a @task?

0 Answers
Related