I have several Flask applications, but they all seem to launch 2 instances of Python. I have no idea why.
Edit: I have googled for Flask and multiple instances of Python, etc, but not one of my searches led me to the 'already answered question' here. I find my question much more to the point than: "Why does running the Flask dev server runs itself twice?" Huh? What is the Flask dev server? Does it have anything to do with Python running twice?
It happens because you run your Flask applications in debug mode:
app.run(host='0.0.0.0', debug=True)
Debug mode automatically reloads the source files when they change. This is implemented so that Flask (actually, Werkzeug, a library used by Flask) spawns another Python interpreter, which monitors the source files and restarts the other interpreter that is running your Flask app.
If you set debug=False
, you should get only one instance of Python per Flask app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With