Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 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 Reply

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...