def monitor(): _common_init() pid = os.getpid() pid_file = open("%s/scanner.pid" % config.get_directory("pid_dir"), 'w') pid_file.write(str(pid)) pid_file.close() observers = [] for directory, sids in config.get("song_dirs").iteritems(): observer = RWObserver() observer.schedule(FileEventHandler(directory, sids), directory, recursive=True) observer.start() log.info("scan", "Observing %s with sids %s" % (directory, repr(sids))) observers.append(observer) try: while True: time.sleep(1) finally: for observer in observers: observer.stop() for observer in observers: observer.join()
def monitor(): _common_init() pid = os.getpid() pid_file = open("%s/scanner.pid" % config.get_directory("pid_dir"), 'w') pid_file.write(str(pid)) pid_file.close() observers = [] for directory, sids in config.get("song_dirs").iteritems(): observer = watchdog.observers.Observer() observer.schedule(FileEventHandler(directory, sids), directory, recursive=True) observer.start() log.info("scan", "Observing %s with sids %s" % (directory, repr(sids))) observers.append(observer) try: while True: time.sleep(60) _process_album_art_queue() except Exception as e: log.exception("scan", "Exception leaked to top monitoring function.", e) for observer in observers: observer.stop() for observer in observers: observer.join()
def monitor(): _common_init() pid = os.getpid() pid_file = open("%s/scanner.pid" % config.get_directory("pid_dir"), 'w') pid_file.write(str(pid)) pid_file.close() observers = [] for directory, sids in config.get("song_dirs").iteritems(): observer = watchdog.observers.Observer() observer.schedule(FileEventHandler(directory, sids), directory, recursive=True) observer.start() observers.append(observer) try: while True: time.sleep(60) _process_album_art_queue() except: for observer in observers: observer.stop() for observer in observers: observer.join()