-2

I am not able to do because I don't have the status of the currently running background process in the django code.

Request: I need to know the status of the celery background task and render the html page from there

@task_success.connect
def task_sent_handler3(sender=None,result=None,**kwargs):
    # information about task are located in headers for task messages
    # using the task protocol version 2.
    #info = headers if 'task' in headers else body
    tester()
    #print('after_task_publish for task id {info[id]}'.format(info="hhhi",))

I tried the above celery annotation but i did not return anything. If it return also will i be able to access the local variables and return the render function

render(request,'page.html') from that success decoration function

How can I tackle this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
SBN AB
  • 161
  • 1
  • 1
  • 17
  • 2
    Render it where? background is just that, in the background. To which potential client should it render the html page for? – Sayse Jul 06 '17 at 08:14

1 Answers1

0

when you run the task for every task there will be unique id for that. from that id you can track the status of the task. on front side you can just check the status of sending the ajax call for that id. when it gets complete you can display the whatever you want to display.

http://thoslin.github.io/async-download-with-celery/

aman kumar
  • 3,086
  • 1
  • 17
  • 24
  • Thanks for the link.. I am new to Ajax, my background task takes 1 hour to complete, can i make Ajax call to wait untill Task.Ready() returns true. When it returns true, i want to call a html page. Can you please share me the Ajax call that will satisfy my need... Thanks – SBN AB Jul 06 '17 at 11:04