def reload_config(self): log.info("Stopping running tasks...") signal.signal(signal.SIGCHLD, signal.SIG_DFL) self.stop_all_tasks() signal.signal(signal.SIGCHLD, mirror.handler.sigchld_handler) log.info("Clearing old data...") self.tasks = odict(filter(lambda x:x[1].isinternal,self.tasks.items())) self.queue = Queue() log.info("Reloading new configs...") self.config = ConfigManager("mirror.ini", need_reload = True) self.init_general(self.config) self.init_tasks (self.config)
def __init__(self, options=None, args=None): # The name is "Scheduler" super(Scheduler, self).__init__(self.__class__.__name__) # self.tasks contains all tasks needed to run in theory, # including the tasks that are not enabled self.config = ConfigManager("mirror.ini") self.tasks = odict() self.queue = Queue() self.todo = self.SCHEDULE_TASK # the number of tasks that enabled self.active_tasks = -1 self.roused_by_child = False self.init_general(self.config) self.init_tasks(self.config)
def reload_config(self): log.info("Stopping running tasks...") signal.signal(signal.SIGCHLD, signal.SIG_DFL) self.stop_all_tasks() signal.signal(signal.SIGCHLD, mirror.handler.sigchld_handler) log.info("Clearing old data...") for taskname, task in self.tasks.iteritems(): if not task.isinternal: del self.tasks[taskname] self.queue = Queue() log.info("Reloading new configs...") self.config = ConfigManager("mirror.ini", need_reload=True) self.init_general(self.config) self.init_tasks(self.config)
def run(self): pass def stop(self): pass # from name to Task TASK_TYPES = {"simple": SimpleTask} if __name__ == "__main__": import mirror.log mirror.log.setupLogger(level="info", filename="/home/ideal/.config/mirror/mirrord.log", filemode="a") from mirror.configmanager import ConfigManager config = ConfigManager("mirror.ini") task = Task('archlinux', None, **config['archlinux']) # The date to Shanghai since = time.mktime((2013, 7, 20, 8, 0, 0, 0, 0, 0)) print(time.ctime(task.get_schedule_time(since))) print(task.get_args()) #task.run() #time.sleep(100) task = Task('ubuntu', None, **config['ubuntu']) print(time.ctime(task.get_schedule_time(time.time()))) print(task.get_args()) print(task.get_args(stage=2))