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
225 views
in Technique[技术] by (71.8m points)

python - render a template and Keep running another background task in Django

I would line to run a function without interrupting the current function as follows

def taskone(request):
    #processes of task one
    tasktwo()
    return render(request,"index.html")

As taskone executes, tasktwo should also start executing. Task one should allow task two to continue executing in the background as it renders the html page.

Please someone give me an idea on how to go about it.

question from:https://stackoverflow.com/questions/65902146/render-a-template-and-keep-running-another-background-task-in-django

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

1 Answer

0 votes
by (71.8m points)

I would recommend you the django-after-response. This is much easier to set up than celery also less process heavy. Only use celery if you need something complex like scheduling tasks, running multiple queues etc.


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

...