Example #1
0
 def io_counters(self):
     try:
         ret = cext.proc_io_counters(self.pid)
     except OSError:
         err = sys.exc_info()[1]
         if err.errno in ACCESS_DENIED_SET:
             ret = cext.proc_io_counters_2(self.pid)
         else:
             raise
     return _common.pio(*ret)
Example #2
0
 def io_counters(self):
     try:
         ret = cext.proc_io_counters(self.pid)
     except OSError:
         err = sys.exc_info()[1]
         if err.errno in ACCESS_DENIED_SET:
             ret = cext.proc_io_counters_2(self.pid)
         else:
             raise
     return _common.pio(*ret)
Example #3
0
 def io_counters(self):
     fname = "/proc/%s/io" % self.pid
     f = open(fname, 'rb')
     SYSCR, SYSCW = b("syscr"), b("syscw")
     READ_BYTES, WRITE_BYTES = b("read_bytes"), b("write_bytes")
     try:
         rcount = wcount = rbytes = wbytes = None
         for line in f:
             if rcount is None and line.startswith(SYSCR):
                 rcount = int(line.split()[1])
             elif wcount is None and line.startswith(SYSCW):
                 wcount = int(line.split()[1])
             elif rbytes is None and line.startswith(READ_BYTES):
                 rbytes = int(line.split()[1])
             elif wbytes is None and line.startswith(WRITE_BYTES):
                 wbytes = int(line.split()[1])
         for x in (rcount, wcount, rbytes, wbytes):
             if x is None:
                 raise NotImplementedError(
                     "couldn't read all necessary info from %r" % fname)
         return _common.pio(rcount, wcount, rbytes, wbytes)
     finally:
         f.close()
Example #4
0
 def io_counters(self):
     fname = "/proc/%s/io" % self.pid
     f = open(fname, 'rb')
     SYSCR, SYSCW = b("syscr"), b("syscw")
     READ_BYTES, WRITE_BYTES = b("read_bytes"), b("write_bytes")
     try:
         rcount = wcount = rbytes = wbytes = None
         for line in f:
             if rcount is None and line.startswith(SYSCR):
                 rcount = int(line.split()[1])
             elif wcount is None and line.startswith(SYSCW):
                 wcount = int(line.split()[1])
             elif rbytes is None and line.startswith(READ_BYTES):
                 rbytes = int(line.split()[1])
             elif wbytes is None and line.startswith(WRITE_BYTES):
                 wbytes = int(line.split()[1])
         for x in (rcount, wcount, rbytes, wbytes):
             if x is None:
                 raise NotImplementedError(
                     "couldn't read all necessary info from %r" % fname)
         return _common.pio(rcount, wcount, rbytes, wbytes)
     finally:
         f.close()
Example #5
0
 def io_counters(self):
     rc, wc, rb, wb = cext.proc_io_counters(self.pid)
     return _common.pio(rc, wc, rb, wb)