1

我有一个简单的代码,应该会在触发下一次火灾时导致之前的工作没有完成。

在这个程序中,我打算在 3 秒后打印 hello world,所以为了制造失火,我让作业睡眠超过 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',minute='0',second='0'],下次运行时间:2015-05 -14 00:00:00)" 被 0:00:02.493426 遗漏,以便我可以测试程序中的合并?

4

1 回答 1

0

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

于 2015-05-20T22:31:10.460 回答