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