flask to execute other tasks after return render_template
<p>In flask app, I need to execute other task's <code>checkJob</code> function (checking the job status and email to the the user) after executing <code>return render_template(page)</code>. The user will see the confirm page but there is still background job running to check the job status.</p>

<p>I tried to use celery <a href="https://blog.miguelgrinberg.com/post/using-celery-with-flask" rel="nofollow noreferrer">https://blog.miguelgrinberg.com/post/using-celery-with-flask</a> for the background job and it does not work. Anything after <code>return render_template(page)</code> is not being executed. </p>

<p>Here's the code fragment:</p>

<pre><code>@app.route("/myprocess", methods=['POST'])
def myprocess():
    //.... do work
    #r = checkJob()
    return render_template('confirm.html')
    r = checkJob()

@celery.task()
def checkJob():
    bb=1
    while bb == 1:
       print "checkJob"
       time.sleep(10)
</code></pre>