I have a flask application which I want to perform an update task every minute via a thread.
The thread is setup like this:
def print_thread():
print "I am a thread"
@app.before_first_request
def start_thread():
threading.Timer(60, print_thread).start()
The flask application is running via uwsgi
:
uwsgi_python -s /tmp/uwsgi.sock --processes 1 --threads 4 -w app:app --enable-threads
I have run into this problem before and solved it by having a flask
endpoint which is called every minute via cron
, but I want a cleaner solution which is self contained in the flask
application.
Can anybody identify the problem?
Or know of a clean solution to solve this problem?
Thanks