def open(self, path, flags): if path in self.writing_files: return 0 # method does not have thread race problem, open by one thread only try: if path not in self.downloading_files: url = self.disk.getRestUrl(path) x = Task(url, path, self.disk) x.start() self.downloading_files[path] = x except Baidu8Secs as e: logger.exception(e) except Exception as e: logger.exception(e) return 0
def run(config): # load backends backends = core.backend.load_backends(config["backends"]) for task in config["tasks"]: # load task effects effects = [] for effect_config in task["effects"]: effect = core.effect.load_effect(effect_config, backends) effects.append(effect) # load the source source = core.source.load_source(task["source"]) # create a new thread for the task task = Task(task["interval"], source, effects) task.start()