示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 def cpu_times(self):
     user, system = cext.proc_cpu_times(self.pid)
     return _common.pcputimes(user, system)
示例#6
0
 def cpu_times(self):
     user, system = cext.proc_cpu_times(self.pid)
     return _common.pcputimes(user, system)