最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - how to run every missed APScheduler job on process restart? - Stack Overflow

programmeradmin2浏览0评论

I am currently using APScheduler+fastapi to run an api that manages scheduling requests and executes them as an openshift deployment. It is great at timing my tasks, however when the pod restarts it causes many tasks that are missed to be skipped. I would like to prevent that, and make them all run when the pod comes back up instead of waiting for the next trigger. I tried pausing the scheduler on app shutdown using FastAPI's lifespan, but this doesn't do the trick. I am aware of this thread, however my tasks are async and therefore I have to use AsyncIOScheduler. In the APScheduler user guide, the following is written:

If the execution of a job is delayed due to no threads or processes being available in the pool, the executor may skip it due to it being run too late (compared to its originally designated run time). If this is likely to happen in your application, you may want to either increase the number of threads/processes in the executor, or adjust the misfire_grace_time setting to a higher value.

However, setting a high misfire_grace_time seems like a patch to me, as I want to run the jobs immediately regardless of the pod down time, given that they were missed. Is there any solution to this problem? I thought that maybe there exists a built in function for the scheduler to give me the missed jobs so I can run them manually but I haven't found one

发布评论

评论列表(0)

  1. 暂无评论