Example #1
0
 def threads(self):
     thread_ids = os.listdir("/proc/%s/task" % self.pid)
     thread_ids.sort()
     retlist = []
     hit_enoent = False
     for thread_id in thread_ids:
         try:
             f = open("/proc/%s/task/%s/stat" % (self.pid, thread_id), 'rb')
         except EnvironmentError:
             err = sys.exc_info()[1]
             if err.errno == errno.ENOENT:
                 # no such file or directory; it means thread
                 # disappeared on us
                 hit_enoent = True
                 continue
             raise
         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
         ntuple = _common.pthread(int(thread_id), utime, stime)
         retlist.append(ntuple)
     if hit_enoent:
         # raise NSP if the process disappeared on us
         os.stat('/proc/%s' % self.pid)
     return retlist
Example #2
0
 def threads(self):
     thread_ids = os.listdir("/proc/%s/task" % self.pid)
     thread_ids.sort()
     retlist = []
     hit_enoent = False
     for thread_id in thread_ids:
         try:
             f = open("/proc/%s/task/%s/stat" % (self.pid, thread_id), 'rb')
         except EnvironmentError:
             err = sys.exc_info()[1]
             if err.errno == errno.ENOENT:
                 # no such file or directory; it means thread
                 # disappeared on us
                 hit_enoent = True
                 continue
             raise
         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
         ntuple = _common.pthread(int(thread_id), utime, stime)
         retlist.append(ntuple)
     if hit_enoent:
         # raise NSP if the process disappeared on us
         os.stat('/proc/%s' % self.pid)
     return retlist
Example #3
0
 def threads(self):
     rawlist = cext.proc_threads(self.pid)
     retlist = []
     for thread_id, utime, stime in rawlist:
         ntuple = _common.pthread(thread_id, utime, stime)
         retlist.append(ntuple)
     return retlist
Example #4
0
 def threads(self):
     rawlist = cext.proc_threads(self.pid)
     retlist = []
     for thread_id, utime, stime in rawlist:
         ntuple = _common.pthread(thread_id, utime, stime)
         retlist.append(ntuple)
     return retlist
Example #5
0
 def threads(self):
     ret = []
     tids = os.listdir('/proc/%d/lwp' % self.pid)
     hit_enoent = False
     for tid in tids:
         tid = int(tid)
         try:
             utime, stime = cext.query_process_thread(self.pid, tid)
         except EnvironmentError:
             # ENOENT == thread gone in meantime
             err = sys.exc_info()[1]
             if err.errno == errno.ENOENT:
                 hit_enoent = True
                 continue
             raise
         else:
             nt = _common.pthread(tid, utime, stime)
             ret.append(nt)
     if hit_enoent:
         # raise NSP if the process disappeared on us
         os.stat('/proc/%s' % self.pid)
     return ret
Example #6
0
 def threads(self):
     ret = []
     tids = os.listdir('/proc/%d/lwp' % self.pid)
     hit_enoent = False
     for tid in tids:
         tid = int(tid)
         try:
             utime, stime = cext.query_process_thread(
                 self.pid, tid)
         except EnvironmentError:
             # ENOENT == thread gone in meantime
             err = sys.exc_info()[1]
             if err.errno == errno.ENOENT:
                 hit_enoent = True
                 continue
             raise
         else:
             nt = _common.pthread(tid, utime, stime)
             ret.append(nt)
     if hit_enoent:
         # raise NSP if the process disappeared on us
         os.stat('/proc/%s' % self.pid)
     return ret