Python APScheduler不能运行所有作业

时间:2020-01-24 21:34:37

标签: python apscheduler

我试图运行一个每小时运行一些功能的代码,我使用APScheduler模块使调度程序在所需的时间间隔(1小时)内执行一次。我的问题是,当我运行代码时,它不会运行所有功能,但不会运行18个(我拥有的功能总数)。

阅读该模块的文档后,我了解到,如果设置ThreadPoolExecutor,则可以设置要运行的max函数的数量。当我设置参数minutes = 5时,它起作用了,但是当我设置hours = 1时,发生了上面所说的事情。

我需要代码每小时运行一次每个功能,任何人都知道我该怎么办?

下面的代码尝试执行我所说的

from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from module import func1
from module import func1
...
from module import func18

total_func = [func1, ... , func18]

executors = {
    'default': ThreadPoolExecutor(18),
    'processpool': ProcessPoolExecutor(18)
    }
scheduler = BackgroundScheduler(executors=executors)

start_time = '2020-01-24 17:59:00'
end_time = '2020-01-26 17:59:00'

hours = 1

for func in total_func:
    scheduler.add_job(func, 'interval', hours = horas,
                      start_date = start_time,
                      end_date = end_time)
scheduler.start()

谢谢!

0 个答案:

没有答案