Multiprocess within flask app spinning up 2 processes Multiprocess within flask app spinning up 2 processes flask flask

Multiprocess within flask app spinning up 2 processes


This is a problem with the Flask auto-reload feature, which is used during development to automatically restart the webserver when changes in code is detected, in order to serve up the new code without requiring a manual restart.

In the guide, the “app.run()” call is always placed within an “if __name__ == ‘__main__’” condition, since the reloader is set to on by default. When using multiprocessing, this condition will result in false, so you have to instead disable the Flask autoreload when using it in a function like so:

def startWebserver():          app.run(debug=True, use_reloader=False)

Link for reference:

http://blog.davidvassallo.me/2013/10/23/nugget-post-python-flask-framework-and-multiprocessing/