Skip to content

Celery integration captures retried exceptions that it shouldn't when one task directly calls another #370

Closed

Description

I have one Celery task that directly calls another, but as a function, not as a task. The first task is auto-retried for a certain set of exceptions, and the second task is retried for a different set of exceptions. Here is an example task in my actual codebase, but here is an isolated illustration of the problem.

Consider the following two tasks, bar which is auto-retried for exceptions A or B, and a wrapper task bat which is auto-retried for exceptions C or D.

def foo():
    ...  # do something that might raise exception A, B, C, or D

@app.task(autoretry_for=(A, B))
def bar():
    return foo()

@app.task(autoretry_for=(C, D))
def bat():
    return bar()

Now invoke bat:

bar.delay()

Now suppose that during the execution of bat, foo() raises exception C. Even though Celery will retry the task, the exception C will be reported to Sentry.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions