Skip to content Skip to sidebar Skip to footer

Is There A Way To Receive A Notification As Soon As A Certain Task With A Certain Task Id Is Successful Or Fails Using Celery For Python?

I want to know if there is a way to monitor whether or not a task completes or fails as soon as it does using python celery. I have an event I want to fire up based on the results

Solution 1:

You can run your task as a celery @shared_task with a try except block inside:

@shared_task
def my_task(input1, input2, ...):
    Setting up...
    try:
        Do stuff
        fire_success_event() <- Your success event
    except Exception:
        The above stuff failed
        fire_fail_event() <- your fail eventreturn 1 <- fail
    return 0 <- success

Good luck :)

Post a Comment for "Is There A Way To Receive A Notification As Soon As A Certain Task With A Certain Task Id Is Successful Or Fails Using Celery For Python?"