How do you update Celery Task State/Status to see it in Flower?

12 views Asked by At

When using a Python Celery Task callback to process tasks on a Redis Queue, how do you dynamically change state/status to show interim updates within Flower?

@shared_task(queue='my_queue', bind=True)
def process_event( self, payload ):
    self.update_state( state="PROGRESS", meta={ 'current': 1, 'max': 10 } )
    time.sleep( 5 )

    self.update_state( state="SUCCESS" )
    time.sleep( 5 )

    return true

For some reason, Flower only displays "Started" and "Success" or "Failure".

Is there something I'm doing wrong?

Do I need to use a separate Task for updating the Status and call it asynchronously within the Task?

I tried various combinations including changing the state within the debug console of Visual Studio Code.

I know the state and status updated because I can fetch it back out, but Flower won't show it.

Any ideas? I'm going to try using a separate async Task next just to see if it will work.

0

There are 0 answers