Start a flask application in separate thread

前端 未结 4 513
粉色の甜心
粉色の甜心 2020-11-27 17:51

I\'m currently developing a Python application on which I want to see real-time statistics. I wanted to use Flask in order to make it easy to use and to underst

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 18:36

    You're running Flask in debug mode, which enables the reloader (reloads the Flask server when your code changes).

    Flask can run just fine in a separate thread, but the reloader expects to run in the main thread.


    To solve your issue, you should either disable debug (app.debug = False), or disable the reloader (app.use_reloader=False).

    Those can also be passed as arguments to app.run: app.run(debug=True, use_reloader=False).

提交回复
热议问题