The situation is the following:
I have an app which uses Angularjs for the front-end and Flask for the back-end.
And I have a route that looks like:
@app.route('/api/route1', methods=['POST'])
def route1():
result = some_package.long_task()
result2 = some_package.short_task(result)
return jsonify(result)
The long_task
function is executing some bash commands using check_output
, using the database, reading and writing files and so on. It can take a couple of hours to get finished.
Let's say that the user gets tired of waiting and closes the browser window 10 minutes after the process started.
My questions are:
- Will both
long_task
andshort_task
will be executed anyway? - Is it possible that this situation creates any memory leakage?
- Is it possible to know that the user closed the browser at some point? (including when I try to return the response: would it be possible to know that the response wasn't delivered?)
- Does the answer of this question depends on what server am I using? (Tornado, uWSGI...)
Thanks a lot for your answers.