问题
from apscheduler.scheduler import Scheduler
import os
class ListHref():
def __init__(self):
print 'In ListHref Class!'
self.name_hrefs = {}
self.name_img = {}
self.path = os.path.dirname(__file__)
print 'Out ListHref Class'
def other_function():...
def job(): #function named job
print 'In job!'
book_href = ListHref()
print 'book_href created!'
if __name__ == "__main__":
sched = Scheduler()
#job() #it's ok if job() called only
sched.daemonic = False #non daemon thread
sched.add_interval_job(job,minutes=0.1)
sched.start()
Problem: If call job() only instead of sched,it's ok So I am confused that why the init(self) cannot called completely? and what's wrong with 'No handerls could be found for logger "apscheduler.scheduler"'? Above python code result:
In job()
In ListHref Class!
No handerls could be found for logger "apscheduler.scheduler"
In job()
In ListHref Class!
In job()
In ListHref Class!
...(so on)
回答1:
apscheduler is using the python logging module which needs to be initialized. Logging is a bit complicated (see the link) but the minimum is to:
import logging
logging.basicConfig()
basicConfig supports some common logging features but its worth figuring out some of the more sophisticated uses for the logger.
来源:https://stackoverflow.com/questions/17528363/no-handlers-could-be-found-for-logger-apscheduler-scheduler