Search code examples
pythonflaskuwsgi

How can i update flask templates without restarting the uwsgi instance?


I have a flask application using an uwsgi instance. This application runs some threads in background when a cron command starts. Is there a method for updating my template files without restarting the uwsgi service ?

Currently I'm waiting for my threads to stop and then reloading the uwsgi service.


Solution

  • Enabling TEMPLATES_AUTO_RELOAD works nicely:

    app = Flask(__name__)
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    

    Whether to check for modifications of the template source and reload it automatically. By default the value is None which means that Flask checks original file only in debug mode.

    Source: http://flask.pocoo.org/docs/0.12/config/