我目前有一个app.route,当它被触发时,它会启动一个线程,并假设返回一个模板。但是,它当前没有返回模板,但是如果我注释掉线程,它就会返回。是否有任何解决方法?@app.route('/start', methods=['POST'])def start(): windowname = request.form['windowname'] Thread(target = runBot(windowname)).start() #when commented out the next line is called return render_template('bot.html', isActive = True) #this line isn't being called
1 回答
慕村225694
TA贡献1880条经验 获得超4个赞
我认为问题在于您正在调用函数,而不是将其传递给线程。试试这个:
@app.route('/start', methods=['POST'])def start(): windowname = request.form['windowname'] Thread(target=runBot, args=(window,)).start() # pass the function, and the argument in the args parameter return render_template('bot.html', isActive = True)
添加回答
举报
0/150
提交
取消