6

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!

Community
  • 1
  • 1
Homer
  • 189
  • 1
  • 10
  • try this https://stackoverflow.com/questions/18213619/sharing-a-lock-between-gunicorn-workers – opyate Oct 05 '17 at 14:19

0 Answers0