Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

512
Visualizações
Celery, calling delay with countdown

I'm trying to understand how celery works

In my django application in tasks.py file I have created one task:

@celery.shared_task(default_retry_delay=2 * 60, max_retries=2)
def my_task(param1, param2):
    # There are some operations

I call this task by using this code:

my_task.delay(param1, param2)

Inside of this my_task there is one condition where this task should be started again but after one minute delay

I have found that there are some kind of ETA and countdown for tasks, but their examples are only with apply_async

Is it possible to use some kind countdown for delay?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

From basic part of celery Calling documentation

delay(*args, **kwargs)

Shortcut to send a task message, but doesn’t support execution options.

So delay is clearly convenient, but if you want to set additional execution options you have to use apply_async.

As documentation states delay cannot be used with additional options set so you should just convert your call into apply_async

If you want to add execution options, the docs suggest you use a signature. e.g:

my_task.s(arg1, arg2).apply_async(countdown=60)
over 4 years ago · Santiago Trujillo Relatório

0

Just to add to iklinac's answer. This is how you would call the task using apply_async()

my_task.apply_async(args=(param1, param2), countdown=60)

or

my_task.apply_async(kwargs={'param1':param1, 'param2':param2}, countdown=60)

The second option will really come in handy if you are using a tool like Flower for monitoring. You can look at Celery tasks best practices page for other tips.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda