I'm following up on this post where-in-flask-gunicorn-to-initialize-application. Specifically, I'm looking for what is the best pattern of initializing a connection pool (REDIS in my example) inside a Flask-Gunicorn application. Relating to the above link, I can put a setup code. Having said that - for every worker in Gunicorn this code will re-run. Is this the proper strategy of working with connection pools? There's also the possibility of of using the preload_app configuration, but I do wish to maintain the convenient application reloading.
I think my question can be generalized to - "what is the best pattern in flask/gunicorn for having an initializing code running only once for all workers?" (something a-la singleton).
Thanks!