apsheduler python未按计划运行

问题描述 投票:1回答:1

即使我等待了十多分钟,job_function也不会执行一次。

from apscheduler.schedulers.background import BackgroundScheduler
import send_mail


def job_function():
    print("Hello World")

    send_mail('[email protected]')

sched = BackgroundScheduler()

sched.add_job(job_function, 'interval', minutes=1)

sched.start()
python apscheduler
1个回答
0
投票

基于此代码,并且仅此代码,问题看起来像您的程序在达到时间限制之前就终止了。

尝试在程序的末尾添加此无限循环,这将阻止它退出:

while True:
    time.sleep(1000)

然后使用CTRL + C终止程序。

© www.soinside.com 2019 - 2024. All rights reserved.