[Flask] Separate initialization for each worker in Flask+Gunicorn
Abhijeet Rastogi
abhijeet.1989 at gmail.com
Mon Jan 18 02:31:33 EST 2016
Hi All,
My flask application views contact an API endpoint during the lifetime of
requests. Each of these API request requires a token. Due to the server
side limitation, I can't have two threads using the same token for
initiating requests.
Requirements:-
- To contact this API, I need to fetch an API token. I would like to do
this once per worker and then share that value among views. (just a
read-only variable).
- I want each "worker" that serves requests to have a separate "token".
How can that be achieved in Flask?
- I don't want to issue a fresh token each time a request is served as
that'll be horribly slow.
How do I make that possible in Flask? Any help is appreciated.
Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160118/4c27115c/attachment.html>
More information about the Flask
mailing list