【发布时间】:2020-09-07 01:42:54
【问题描述】:
我编写了一个 Flask 应用程序,它需要一个辅助线程来在浏览器中显示视频流。 以下是线程的创建方式:
if __name__ == '__main__':
# # start a thread that will perform motion detection
t = threading.Thread(target=prepare_video_stream)
t.daemon = True
t.start()
print(t.is_alive())
app.run(debug=True, threaded=True, use_reloader=False)
当使用内置的烧瓶服务器运行我的应用程序时一切正常,但是在使用 gunicorn 部署到 heroku 后,线程似乎没有启动。 这是我的 Procfile:
web: gunicorn app:app
如何使线程运行?我错过了什么吗?
【问题讨论】:
标签: python flask heroku python-multithreading