我在烧瓶应用程序中使用预定任务:
import time
import atexit
from apscheduler.schedulers.background import BackgroundScheduler
def intervall():
with app.app_context():
call_function_to_do()
scheduler = BackgroundScheduler()
scheduler.add_job(func=intervall, trigger="interval", seconds=5)
scheduler.start()
# Shut down the scheduler when exiting the app
atexit.register(lambda: scheduler.shutdown())
我的问题是所有的gunicorn工作者都在启动调度程序任务。在这种情况下,检查超时情况并向用户发送电子邮件。
有没有人知道如何让一个工人执行qazxsw poi?