0Pricing
Flask Academy · Lesson

Track Results and Handle Failures

Poll task state and retry on error.

The AsyncResult Handle

When you enqueue a task you get an AsyncResult. Save its id so you can check on the job from any later request.

job = add.delay(2, 3)
ticket = job.id

Check the State

Each job has a state like PENDING, STARTED, SUCCESS, or FAILURE. You read it to know whether the work is done.

res = add.AsyncResult(ticket)
print(res.state)

All lessons in this course

  1. Why Move Work Off the Request
  2. Wire Celery into the App Factory
  3. Define and Call a Task
  4. Track Results and Handle Failures
← Back to Flask Academy