def __init__(self, rtc, cpus=None): threading.Thread.__init__(self) self.daemon = True self.__logfp = None self.__cpus = cpus or set() self.__lock = threading.RLock() self.__rtc = rtc self.__pptr = None self.__logfp = None self.__pid = -1 self.__killThread = None self.__wasKilled = threading.Event() self.__hasStarted = threading.Event() self.__isShutdown = threading.Event() self.__progressLock = threading.Lock() self.__progress = 0.0 self.__lastLog = "" self.__metricsLock = threading.Lock() self.__metrics = { 'rssMb': 0, 'maxRssMb': 0, 'cpuPercent': 0, 'diskIO': ttypes.DiskIO(-1,-1,-1,-1), }
for i, val in enumerate(counters): disk_io[i] += val except psutil.NoSuchProcess, e: return cpu_perc_int = int(round(cpu_perc)) rssMb = rss_bytes / 1024 / 1024 metrics = self.__metrics with self.__metricsLock: maxRss = max(rssMb, metrics['maxRssMb']) disk_io_t = ttypes.DiskIO(*disk_io) if do_disk_io else None metrics.update({ 'rssMb': rssMb, 'maxRssMb': maxRss, 'cpuPercent': cpu_perc_int, 'diskIO': disk_io_t, }) logger.debug("metrics: %r", metrics) def killProcess(self, block=True): """ killProcess(bool block=True) -> (list killed_pids, list not_killed) Stop the entire process tree