问题
I'm using celery
with rabbitMQ
as a broker to manage asynchronous tasks.
I'm chording some tasks together and when each of them has finished, I'm running a concatenation task that will join each result. These collection of tasks is identified by a report_id set by me.
chord([task1.s(report_id=report_id), task2.s(report_id=report_id)...]) \
(concat_task.s(report_id=report_id).set(queue='default') \
.on_error(on_chord_error.s().set(queue='default')))
And this is my custom on_error
task:
@celery_app.task
def on_chord_error(request, exc, traceback):
logger.error('Chord {0!r} raised error: {1!r}'.format(request.id, exc), exc_info=(type(exc), exc.args, traceback))
# BaseHandler.remove_placeholder(???report_id???) # cleaning action
My problem is on the on_error
: Every time the chord fails (for any reason) I need to have the report_id (not to be confused with the request.id) passed to it in order to perform a cleaning action. However the documentation I found is vague on this. It seems I cannot pass the request_id as parameter of the task signature as I am doing for the singles and concatenation tasks.
Any help would be appreciated
来源:https://stackoverflow.com/questions/59575336/pass-parameters-to-celery-on-error-task