Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

python - Celery chord errback not firing

According to the docs https://docs.celeryproject.org/en/stable/userguide/canvas.html#error-handling I can attach an error callback to chord.

To perform an action when a chord fails you can therefore attach an errback to the chord callback

I tried that out, but it seems the error callback is not getting called. It just throws the exception as usual and then keeps on printing these 2 lines forever:

Task celery.chord_unlock[eaa5cb7b-a7a7-4d4a-8f88-2ab91d13e8b1] retry: Retry in 1.0s: DecodeError(JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))

Received task: celery.chord_unlock[eaa5cb7b-a7a7-4d4a-8f88-2ab91d13e8b1] ETA:[2021-01-25 13:38:55.672567+05:30]

Here's the code that I used:

tasks.py

from celery import shared_task


@shared_task
def add(x, y):
    return x + y


@shared_task
def throw_error():
    raise Exception("Test Error")


@shared_task
def print_results(results):
    print(results)


@shared_task
def error_handling(request, exc, traceback):
    print(f"{request.id} - {exc}")

Running the tasks:

task_id = chord(
    [add.s(10, 20), add.s(20, 30), throw_error.s(), add.s(30, 40)]
)(print_results.s().on_error(error_handling.s()))

Am I doing something wrong or have I misunderstood it?

question from:https://stackoverflow.com/questions/65881362/celery-chord-errback-not-firing

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...