我需要一个带有 APSscheduler 设置的日常功能触发器。然而,APS调度程序只能触发一次。正如我的代码所示,我每天设置 21:00 触发,但只能在第一个 21:00 触发。
#!/usr/bin/env python
from apscheduler.schedulers.background import BackgroundScheduler
# Running Timer
scheduler = BackgroundScheduler(timezone='asia/taipei')
def push_today():
# Running with my triggered code
def entry_point(upgrade_hint):
scheduler.add_job(push_today, 'cron', year='*', month='*', day="*", hour=21, minute=0, second=0)
scheduler.start()
# Flask app
entry.app.run(host='0.0.0.0', port=8080)
if __name__ == "__main__":
entry_point()
谢谢
[20231023 - 更新] 我观察到我的应用程序上出现“作业 XXX 的运行时间被 0:00:03.054418 错过”。看来 apscheduler 有一种机制,可以在错过我配置的时间时忽略 cron 作业。
我将添加 Misfire_grace_time、coalesce 和 max_instances 来再次测试。
添加misfire_grace_time、coalesce和max_instances参数可以解决这个问题。
谢谢