'Check for changes in self.paths or self.cache and call the event handler.'

def check(self):

    hashes = {key: None for key in self.paths.keys()}
    while self._active:
        do_reload = False
        with self._lock:
            paths = list(self.paths.keys())
        for path in paths:
            if (not os.path.exists(path)):
                continue
            mod_time = self.paths[path]
            if (not hashes.get(path, None)):
                hashes[path] = md5_hash_file(path)
            new_mod_time = None
            if os.path.exists(path):
                new_mod_time = os.path.getmtime(path)
            if (new_mod_time > mod_time):
                new_hash = md5_hash_file(path)
                if (hashes[path] != new_hash):
                    self.paths[path] = new_mod_time
                    hashes[path] = new_hash
                    log.debug("The    file    '%s'    has    changes.", path)
                    do_reload = True
        if ((not do_reload) and self.cache):
            removed_ids = self.cache.cleanup()
            if removed_ids:
                do_reload = True
        if do_reload:
            self.reload_callback()
        time.sleep(1)
