Python Flask + Threaded function
<p>I would like to make a function, that runs in background and updates a variable every X minutes for my website. </p>

<p>Basically what I need is to cache some json data and update it every X minutes.</p>

<p>What would be the best way to do it? I tried "threading" and it seems to work, but when I run it with Flask, it runs itself 2 times every time. </p>

<p>Well, you may use <a href="http://flask.pocoo.org/docs/0.11/patterns/celery/" rel="nofollow">Celery</a> to create delayed tasks to update your data.</p>

<p>But I don't think, that update variable directly is a good idea. So, store your data in cache or database. It depends on the frequency of how you use and update data.</p>

python multithreading caching flask