为什么在apscheduler中没有产生失火警告

时间:2015-05-20 04:29:15

标签: python-2.7 apscheduler

我有一个简单的代码,因为当下一次触发时,前一个作业没有完成,因此会导致失火。

在这个程序中我打算在3秒后打印你好的世界,所以为了创造失火我让你的工作睡眠超过3秒,所以前一个没有完成。但是我没有得到失火错误。我很困惑。

#!/usr/bin/env python

import sys
from time import sleep
from apscheduler.scheduler import Scheduler
sched = Scheduler()
sched.start()        # start the scheduler

# define the function that is to be executed
# it will be executed in a thread by the scheduler
def my_job():

    print "hello world"
    sleep(10)
    print "nest"

def main():
    # job = sched.add_date_job(my_job, datetime(2013, 8, 5, 23, 47, 5), ['text'])
    job = sched.add_interval_job(my_job,seconds=3)
    while True:
        sleep(1)
        sys.stdout.write('.'); sys.stdout.flush()

##############################################################

if __name__ == "__main__":
    main() 

进一步有没有办法生成作业的运行时间“xxxxx(触发器:cron [day ='*',hour ='0',分钟='0',秒='0'],接下来运行于: 2015-05-14 00:00:00)“错过了0:00:02.493426,以便我可以在程序中测试合并?

1 个答案:

答案 0 :(得分:0)

尝试将线程池的大小减小到1并增加作业的并发执行次数。这应该会让你得到你正在寻找的警告。