Example #1
0
 def makeListThreadsMessage(self, seq):
     """ returns thread listing as XML """
     try:
         t = threading.enumerate()
         cmdText = "<xml>"
         for i in t:
             if t.isAlive():
                 cmdText += self.threadToXML(i)
         cmdText += "</xml>"
         return NetCommand(CMD_RETURN, seq, cmdText)
     except:
         return self.makeErrorMessage(seq, GetExceptionTracebackStr())
Example #2
0
def PydevdFindThreadById(thread_id):
    try:
        # there was a deadlock here when I did not remove the tracing function when thread was dead
        threads = threading.enumerate()
        for i in threads:
            if thread_id == GetThreadId(i):
                return i

        sys.stderr.write("Could not find thread %s\n" % thread_id)
        sys.stderr.write("Available: %s\n" % [GetThreadId(t) for t in threads])
        sys.stderr.flush()
    except:
        traceback.print_exc()

    return None