Python 如何使APScheduler ProcessPoolExecutor在完成后关闭进程,并只生成它所需的进程?
ProcessPoolExecutor生成一组处理apscheduler作业的进程。我期望ProcessPoolExecutor生成的进程在成功完成作业后实际关闭,并为所述作业的下一次执行生成一个新进程。如果没有必要,我也希望不会产生进程。然而,这并没有发生。如果我将max workers设置为10,将生成10个进程。即使唯一作业的最大实例数为3。在其中一个进程完成作业后,该进程不会被回收,只会重新调整用途,以供下次运行所述作业 我举个例子: 使用BlockingScheduler创建apscheduler,并使用ProcessPoolExecutor作为其执行器Python 如何使APScheduler ProcessPoolExecutor在完成后关闭进程,并只生成它所需的进程?,python,apscheduler,Python,Apscheduler,ProcessPoolExecutor生成一组处理apscheduler作业的进程。我期望ProcessPoolExecutor生成的进程在成功完成作业后实际关闭,并为所述作业的下一次执行生成一个新进程。如果没有必要,我也希望不会产生进程。然而,这并没有发生。如果我将max workers设置为10,将生成10个进程。即使唯一作业的最大实例数为3。在其中一个进程完成作业后,该进程不会被回收,只会重新调整用途,以供下次运行所述作业 我举个例子: 使用BlockingScheduler创建apsch
def printing_job():
print("print this...")
def main():
executors = {
'default': ProcessPoolExecutor(max_workers=10)
}
job_defaults = {
'coalesce': False,
'max_instances': 3,
'misfire_grace_time': None
}
scheduler = BlockingScheduler(executors=executors,
daemonic=True,
daemon=True)
scheduler.add_job(printing_job, 'interval', seconds=1)
scheduler.start()
生成了11个进程,10个调度程序进程和主进程:
user 61428 59435 18 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61456 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61457 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61458 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61459 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61460 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61461 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61462 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61463 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61464 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
user 61465 61428 0 16:25 pts/2 00:00:00 ../bin/python3 ./test.py
作业只使用了3个。我最多应该看到4个过程。这些过程应该收获并重新创造
这个范例在APScheduler中不可能吗
ProcessPoolExecutor声明max_workers是最多生成的工作进程数。关键字“最多”对我来说意味着它不应该产生比它需要的更多的东西