5

I have an issue using celery with my DJANGO application. When a task have an error the tasks enter in a loop and start again instead of finish the task My task run a stored procedure from the database. In the stored procedure I have if there any error send an email and exit from the stored procedure.

I have two workers with different concurrency

celery multi start carga_w conc_w -A provcon -Q:conc_w conc -Q:carga_w carga -l info -c:conc_w 1 -c:carga_w 3 -E

task:

@task(queue='conc')
def conci(idprov,pfecha):
    conci = Buscar_Conci()
    spconc = conci.buscarcon(idprov,pfecha)
    return None

Try to purge the task won't work and the task is keep it in memory. To purge the task I use the next command:

celery -A provcon purge -f

Is my first time using Celery with DJANGO and I don't know if I miss something or I have some wrong settings:

BROKER_URL = 'redis://localhost:6379/0'
CELERY_IMPORTS = ("pc.tasks", )
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_RESULT_BACKEND='djcelery.backends.cache:CacheBackend'

To kill the task when enter in that loop I need to kill it from the database because I can't stop from the django-admin site or using the celery purge command

Any advice how to avoid to enter in that loop the tasks when an error is raised

Thanks in advance

joselegit
  • 533
  • 1
  • 14
  • 35

0 Answers0