<div dir="ltr"><div class="gmail_extra">Hi Abhijeet,</div><div class="gmail_extra"><br></div><div class="gmail_extra">You could store the token as an app config value:</div><div class="gmail_extra"><br></div><div class="gmail_extra">app.config['CURRENT_TOKEN'] = 'your_token_here'<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">and then have the workers access the token from the app config. Anytime a worker finds the token is not set or needs an update, simply set/update the same config value.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,<br>Alejo</div><div class="gmail_extra"><br><div class="gmail_quote">On 18 January 2016 at 08:31, Abhijeet Rastogi <span dir="ltr"><<a href="mailto:abhijeet.1989@gmail.com" target="_blank">abhijeet.1989@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi All,<br><br><br>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.<br><br>Requirements:- <br><ul><li>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).<br></li><li>I want each "worker" that serves requests to have a separate "token". How can that be achieved in Flask?<br></li><li>I don't want to issue a fresh token each time a request is served as that'll be horribly slow.<br></li></ul>How do I make that possible in Flask? Any help is appreciated.<div><br></div><div>Thanks! </div></div></blockquote></div><br><br></div></div>