APScheduler missing jobs after adding misfire_grace_time

喜你入骨 提交于 2020-01-03 17:42:47

问题


I am running a BlockingScheduler process that it's suppose to run several cron jobs, but it fails to run every single time with the message:

Run time of job "validation (trigger: cron[hour='3'], next run at: 2016-12-30 03:00:00 CST)" was missed by 0:00:02.549821

I have the following setup:

sched = BlockingScheduler(misfire_grace_time=3600, coalesce=True)
sched.add_jobstore('mongodb', collection='my_jobs')

@sched.scheduled_job('cron', hour=3, id='validation')
def validation():
    rep = Myclass()
    rep.run()

if __name__ == '__main__':
    sched.start()

I thought adding misfire_grace_time would do the trick, but every job is still missing to run.


回答1:


try adding misfire_grace_time in @sched.scheduled_job('cron', hour=3, id='validation', misfire_grace_time=3600)




回答2:


self.scheduler = BlockingScheduler(
    logger=log,
    job_defaults={'misfire_grace_time': 15*60},
)

adding the misfire_grace_time as job_defaults will work



来源:https://stackoverflow.com/questions/41428118/apscheduler-missing-jobs-after-adding-misfire-grace-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!