def cpu_times(self): try: ret = cext.proc_cpu_times(self.pid) except OSError: err = sys.exc_info()[1] if err.errno in ACCESS_DENIED_SET: ret = cext.proc_cpu_times_2(self.pid) else: raise return _common.pcputimes(*ret)
def cpu_times(self): f = open("/proc/%s/stat" % self.pid, 'rb') try: st = f.read().strip() finally: f.close() # ignore the first two values ("pid (exe)") st = st[st.find(b(')')) + 2:] values = st.split(b(' ')) utime = float(values[11]) / CLOCK_TICKS stime = float(values[12]) / CLOCK_TICKS return _common.pcputimes(utime, stime)
def cpu_times(self): user, system = cext.proc_cpu_times(self.pid) return _common.pcputimes(user, system)