for l in lines: if l.startswith("CHECK_" + self.name) is False: continue else: ret.append(l) if len(ret) == 0: time.sleep(20) i += 1 continue else: break except Exception: print traceback.format_exc() raise Exception("read log file failed") finally: f.close() print "{COLLECT LOG INFO END}" return "".join(ret) if __name__ == '__main__': topics = conf.get_topic_name().split(",") i = 0 path = log_config.getLogPath() print str(topics) for t in topics: cp_path = conf.get_cp_path() cp_name = conf.get_cp_name().split(",")[i] i += 1 HealthCheck(path, cp_path, cp_name).check() pass