0
开始无限的Python脚本我想从瓶请求中开始我的永不落幕的Python脚本:在新线程内瓶
def start_process():
exec(open("./process/main.py").read(), globals())
print("Started")
return
,并要求:
@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'))
的main.py
过程是一个小测试服务器,等待一些消息,但它只是挂起整个瓶子脚本(事实上,通过gunicorn,如果我发送CTRL-C,我可以看到子过程的输出)。
如何让main.py
脚本单独启动?
它与我想要做的事情背道而驰,但它总是一种解决方案。 – Alessandro