我想學習如何使用Python的apscheduler包,但週期性的,它引發以下錯誤:如何指定「記錄儀」爲apscheduler
No handlers could be found for logger "apscheduler.scheduler"
此消息似乎是在錯誤相關預定作業,例如使用jobTester作爲預定作業,下面的代碼,它使用在jobTester未定義的變量(nameStr0)給出了上述錯誤消息:
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創建記錄器?我在配置調度程序的文檔部分丟失了一些東西
我正確地認爲這個記錄器是某種類型的stderr嗎?如果是這樣,我在那裏將尋找它(如果未通過的方式來確定我將它設置)