Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No handlers could be found for logger "apscheduler.scheduler"

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)

like image 728
Dyllian Avatar asked Jul 08 '13 13:07

Dyllian


1 Answers

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.

like image 148
tdelaney Avatar answered Oct 15 '22 12:10

tdelaney