【发布时间】:2018-02-02 12:35:54
【问题描述】:
我有一个烧瓶应用程序,我想通过线程每分钟执行一次更新任务。
线程是这样设置的:
def print_thread():
print "I am a thread"
@app.before_first_request
def start_thread():
threading.Timer(60, print_thread).start()
flask 应用程序正在通过uwsgi 运行:
uwsgi_python -s /tmp/uwsgi.sock --processes 1 --threads 4 -w app:app --enable-threads
我之前遇到过这个问题,并通过flask 端点解决了这个问题,该端点每分钟通过cron 调用一次,但我想要一个更干净的解决方案,它是自包含在flask 应用程序中的。
谁能找出问题所在?
或者知道解决这个问题的干净解决方案吗?
谢谢
【问题讨论】:
标签: python multithreading flask uwsgi