Una tarea finita de apio batido

I'm using Celery on a project that integrates with a 3rd party API. I need to send a file to the service for processing. After I send the file I need to request the status of the processing every 10 seconds until it's complete.

As I have it now, the main task will spin off subtasks to check the status of the processing. I'd like these subtasks to act like finite celery beat tasks. I want to start the tasks life when I call it as a subtask and I want to end it when the task is complete.

What's the best way of accomplishing this?

preguntado el 09 de marzo de 12 a las 15:03

1 Respuestas

Use Task.retry, for example:

from celery.result import AsyncResult

@task
def verify_task(task_id):
    result = AsyncResult(task_id)
    if result.ready():
         do_something_with(result.get())
    else:
        verify_task.retry(countdown=1)

The countdown is the number of seconds before the retry.

respondido 10 mar '12, 01:03

Thanks! Good to know that retry is intended to be used outside of Exception handling. - Kenzic

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.