def __init__(self, log, qaConf, g_vars): # connection of any executing entity, here for QA-DKRZ self.qa_exec = QaExec(log, qaConf, g_vars) self.g_vars = g_vars self.is_next=False if qaConf.isOpt('NEXT'): self.is_next=True self.next=qaConf.getOpt('NEXT')
def run(): if qaConf.isOpt("SHOW_EXP"): f_log = get_all_logfiles() sys.exit(0) if qaConf.isOpt('SHOW') or qaConf.isOpt('NEXT'): g_vars.thread_num = 1 # the queue is two items longer than the number of threads queue = Queue(maxsize=g_vars.thread_num + 2) launch_list = [] if g_vars.thread_num < 2: # a single thread qaExec = QaExec(log, qaConf, g_vars) launch_list.append(qaExec) else: for i in range(g_vars.thread_num): launch_list.append(QaLauncher(log, qaConf, g_vars)) for i in range(g_vars.thread_num): t = Thread(target=launch_list[i].start, args=(queue, )) t.daemon = True t.start() is_next_var = False if qaConf.isOpt('NEXT_VAR'): is_next_var = True next_var = qaConf.getOpt('NEXT_VAR') count_next_var = 0 while True: if qaConf.isOpt('EXPLICIT_FILES'): if len(qaConf.dOpts['EXPLICIT_FILES']): data_path, f = os.path.split(qaConf.dOpts['EXPLICIT_FILES'][0]) t_r = qa_util.f_time_range(f) fBase = t_r[0] fNames = [f] del qaConf.dOpts['EXPLICIT_FILES'][0] else: queue.put(('---EOQ---', '', t_vars), block=True) break else: if is_next_var: if count_next_var == next_var: break count_next_var += 1 try: # fBase: list of filename bases corresponding to variables; # usually a single one. F # fNames: corresponding sub-temporal files data_path, fBase, fNames = getPaths.next() except StopIteration: queue.put(('---EOQ---', '', t_vars), block=True) break else: isNoPath = False # return a list of files which have not been processed, yet. # Thus, the list could be empty fL = get_next_variable(data_path, fBase, fNames) if len(fL) == 0: continue t_vars.fBase = fBase #queue.put( (data_path, fL, t_vars), block=True) queue.put((data_path, fL, copy.deepcopy(t_vars)), block=True) if g_vars.thread_num < 2: # a single thread if not launch_list[0].start(queue, ): break if g_vars.thread_num > 1: queue.join() if g_vars.thread_num < 2: launch_list[0].printStatusLine() else: launch_list[0].qa_exec.printStatusLine() return