Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

python 2.7 - How will I know if celery background process is successful inside django code. If it is successful I want render a html page

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...