请问下,哪位大神知道scheduler.add_job()的方法

定时器的方法如果上一个定时器任务没有执行完,下一个任务就开始执行,会把上一个任务停止吗?还是会等待上一个任务完成后再执行,代码:
scheduler.add_job(func=check_insert_data, id=‘job4’, trigger=‘interval’, minutes=2)

1 个赞

如果是用APScheduler这个库来管理定时任务的执行,默认每个任务同时只会用一个实例来运行的,所以如果一个任务没有执行完,会等待执行完后再继续。

你这个问题很好,我也想知道,但是看了英文文档,也么有说明啊

找到了,如下文档,你的需求需要设置这个参数 ‘max_instances’

Limiting the number of concurrently executing instances of a job

By default, only one instance of each job is allowed to be run at the same time. This means that if the job is about to be run but the previous run hasn’t finished yet, then the latest run is considered a misfire. It is possible to set the maximum number of instances for a particular job that the scheduler will let run concurrently, by using the max_instances keyword argument when adding the job.