Initializing Resources in Gunicorn

I am following this post where-in-flask-gunicorn-to-initialize-application . In particular, I am looking for the best example of connection pool initialization (REDIS in my example) inside a Flask-Gunicorn application. Regarding the link above, I can install the installation code. Having said that, for every employee at Gunicorn this code will be re-run. Is this the right connection pooling strategy? It is also possible to use the preload_app configuration, but I want to support a convenient reload of the application.

I think my question can be generalized to: "What is the best sample in the / gunicorn bulb so that the initialization code works only once for all workers?" (something a-la singleton).

Thanks!

+6
source share

All Articles