1

I am using djcelery. I have created one task.

@celery.decorators.periodic_task(run_every=datetime.timedelta(minutes=2))
def add(x, y):
    cont= 0
    print x
    print y
    for i in range(x, y):
        cont = cont+1
    return cont

i clalled it in view.py

def home(request):
    print "debug"
    st = add.delay(63,230)
    return  render(request, 'home/home.html', {})

now how can i detect the task is complete or failed. i want to perform certain actions on success and failure.

Wagh
  • 4,202
  • 5
  • 39
  • 62

1 Answers1

-1

Depends on your use case, but one way would be to save a flag in memory (cache, database, etc) and update it accordingly.

To display any async updates frontend, create an endpoint to check the flag and poll it with ajax.

Hedde van der Heide
  • 21,841
  • 13
  • 71
  • 100