I'd like to start my never ending Python script from within Flask request:
def start_process(): exec(open("./process/main.py").read(), globals()) print("Started") return and with the request:
@app.route("/start") def start(): from threading import Thread thread = Thread(target=start_process, args=()) thread.setDaemon(True) thread.start() return redirect(url_for('main')) The main.py process is a little test server that waits for some messages, but it simply hangs the entire flask script (in fact, through gunicorn, if I send CTRL-C, I can see the output of the subprocess).
How can I make the main.py script start separately?