我想学习如何使用Python的apscheduler包,但周期性的,它引发以下错误:
No handlers could be found for logger "apscheduler.scheduler"
此消息好像是用jobTester作为预定作业与预定作业的错误相关联,例如,下面的代码,它使用一个未定义的变量(nameStr0)在jobTester给出了上述错误消息:
from apscheduler.scheduler import Scheduler
from apscheduler.jobstores.shelve_store import ShelveJobStore
from datetime import datetime, timedelta
from schedJob import toyJob
def jobTester(nameStr):
outFileName = nameStr0 + '.txt'
outFile = open(outFileName,'w')
outFile.write(nameStr)
outFile.close()
def schedTester(jobList):
scheduler = Scheduler()
scheduler.add_jobstore(ShelveJobStore('example.db'),'shelve')
refTime = datetime.now()
for index, currJob in enumerate(jobList):
runTime = refTime + timedelta(seconds = 15)
jobName = currJob.name + '_' + str(index)
scheduler.add_date_job(jobTester, runTime, name = jobName,
jobstore = 'shelve', args = [jobName])
scheduler.start()
stopTime = datetime.now() + timedelta(seconds = 45)
print "Starting wait loop .....",
while stopTime > datetime.now():
pass
print "Done"
def doit():
names = ['Alan','Barbara','Charlie','Dana']
jobList = [toyJob(n) for n in names]
schedTester(jobList)
这可以通过如下运行此代码(存储在文件schedTester.py)中可以看出:
>>> import schedTester
>>> schedTester.doit()
No handlers could be found for logger "apscheduler.scheduler"
Starting wait loop ..... Done
然而,当我替换nameStr的nameStr0(即变量名的正确拼写),代码运行没有错误消息细。
如何创建一个apscheduler.scheduler记录? 我缺少的东西在处理配置调度程序的文档的部分
是这个记录的想法我纠正一些不大不小的标准错误? 如果是这样,我在那里将寻找它(如果不被方式来确定我将它设置)