這是代碼:apscheduler不能正常工作
#coding=utf-8
from apscheduler.scheduler import Scheduler
import logging
logging.basicConfig(filename='/tmp/log', level=logging.DEBUG,
format='%(levelname)s[%(asctime)s]: %(message)s')
sched = Scheduler()
sched.start()
#@sched.interval_schedule(seconds=3)
def job_function():
logging.debug('hello world')
sched.add_interval_job(job_function, seconds=3)
如果我切換到裝飾機,仍然無法正常工作。日誌是這樣的:
DEBUG[2011-10-09 11:02:45,175]: Looking for jobs to run
DEBUG[2011-10-09 11:02:45,176]: No jobs; waiting until a job is added
INFO[2011-10-09 11:02:45,176]: Added job "job_function (trigger: interval[0:00:03], next run at: 2011-10-09 11:02:48.176444)" to job store "default"
INFO[2011-10-09 11:02:45,177]: Shutting down thread pool
job_function
增加,但nerver觸發,爲什麼工作?
找到了原因:喬布斯總是以非守護線程執行。 – limboy
我不知道如何記錄aps呼叫,這個例子幫助了我!謝謝Izzy – daydreamer