[Pydev-cvs] org.python.pydev.debug/pysrc pydevd.py, 1.55, 1.56 pydevd_comm.py, 1.16, 1.17
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2006-08-21 23:22:39
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9572/pysrc Modified Files: pydevd.py pydevd_comm.py Log Message: processing dead threads Index: pydevd_comm.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd_comm.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** pydevd_comm.py 24 Jun 2006 13:55:41 -0000 1.16 --- pydevd_comm.py 21 Aug 2006 23:22:36 -0000 1.17 *************** *** 18,39 **** NUMBER NAME FROM* ARGUMENTS RESPONSE NOTE 100 series: program execution ! 101 RUN RDB - - ! 102 LIST_THREADS RDB RETURN with XML listing of all threads 103 THREAD_CREATE PYDB - XML with thread information ! 104 THREAD_KILL RDB id kills the thread ! PYDB id nofies RDB that thread was killed ! 105 THREAD_SUSPEND RDB XML of the stack, suspends the thread reason for suspension ! PYDB id notifies RDB that thread was suspended ! 106 THREAD_RUN RDB id resume the thread ! PYDB id \t reason notifies RDB that thread was resumed ! 107 STEP_INTO RDB thread_id ! 108 STEP_OVER RDB thread_id ! 109 STEP_RETURN RDB thread_id ! 110 GET_VARIABLE RDB var_locator GET_VARIABLE with XML of var content see code for definition ! 111 SET_BREAK RDB file/line of the breakpoint ! 112 REMOVE_BREAK RDB file/line of the return ! 113 EVALUATE_EXPRESSION RDB expression result of evaluating the expression 114 CMD_GET_FRAME RDB 115 CMD_EXEC_EXPRESSION RDB --- 18,39 ---- NUMBER NAME FROM* ARGUMENTS RESPONSE NOTE 100 series: program execution ! 101 RUN JAVA - - ! 102 LIST_THREADS JAVA RETURN with XML listing of all threads 103 THREAD_CREATE PYDB - XML with thread information ! 104 THREAD_KILL JAVA id kills the thread ! PYDB id nofies JAVA that thread was killed ! 105 THREAD_SUSPEND JAVA XML of the stack, suspends the thread reason for suspension ! PYDB id notifies JAVA that thread was suspended ! 106 THREAD_RUN JAVA id resume the thread ! PYDB id \t reason notifies JAVA that thread was resumed ! 107 STEP_INTO JAVA thread_id ! 108 STEP_OVER JAVA thread_id ! 109 STEP_RETURN JAVA thread_id ! 110 GET_VARIABLE JAVA var_locator GET_VARIABLE with XML of var content see code for definition ! 111 SET_BREAK JAVA file/line of the breakpoint ! 112 REMOVE_BREAK JAVA file/line of the return ! 113 EVALUATE_EXPRESSION JAVA expression result of evaluating the expression 114 CMD_GET_FRAME RDB 115 CMD_EXEC_EXPRESSION RDB *************** *** 47,51 **** 501 ERROR either - This is reserved for unexpected errors. ! * RDB - remote debugger, the java end * PYDB - pydevd, the python end ''' --- 47,51 ---- 501 ERROR either - This is reserved for unexpected errors. ! * JAVA - remote debugger, the java end * PYDB - pydevd, the python end ''' *************** *** 312,317 **** cmdText = "<xml>" for i in t: ! # print 'makeListThreadsMessage', t.additionalInfo.pydev_last_event ! cmdText += self.threadToXML(i) cmdText += "</xml>" return NetCommand(CMD_RETURN, seq, cmdText) --- 312,317 ---- cmdText = "<xml>" for i in t: ! if t.isAlive(): ! cmdText += self.threadToXML(i) cmdText += "</xml>" return NetCommand(CMD_RETURN, seq, cmdText) Index: pydevd.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** pydevd.py 24 Jun 2006 13:55:41 -0000 1.55 --- pydevd.py 21 Aug 2006 23:22:36 -0000 1.56 *************** *** 155,158 **** --- 155,163 ---- STATE_RUN = 1 STATE_SUSPEND = 2 # thread states + RUNNING_THREAD_IDS = {} #this is a dict of thread ids pointing to thread ids. Whenever a command + #is passed to the java end that acknowledges that a thread was created, + #the thread id should be passed here -- and if at some time we do not find + #that thread alive anymore, we must remove it from this list and make + #the java side know that the thread was killed. def __init__(self): *************** *** 211,214 **** --- 216,220 ---- for t in all_threads: if id(t) == thread_id: + self.RUNNING_THREAD_IDS[thread_id] = t cmd = self.cmdFactory.makeThreadCreatedMessage(t) if cmd: *************** *** 246,249 **** --- 252,258 ---- def processInternalCommands(self): + '''This function processes internal commands + ''' + self.acquire() try: *************** *** 254,260 **** --- 263,276 ---- self.checkOutput(sys.stderrBuf,2) + currThreadId = id(threading.currentThread()) threads = threading.enumerate() foundNonPyDBDaemonThread = False + foundThreads = {} + for t in threads: + tId = id(t) + if t.isAlive(): + foundThreads[tId] = tId + if not isinstance(t, PyDBDaemonThread): foundNonPyDBDaemonThread = True *************** *** 265,269 **** while True: int_cmd = queue.get(False) ! if int_cmd.canBeExecutedBy(id(threading.currentThread())): pydevd_log(2, "processing internal command " + str(int_cmd)) int_cmd.doIt(self) --- 281,285 ---- while True: int_cmd = queue.get(False) ! if int_cmd.canBeExecutedBy(currThreadId): pydevd_log(2, "processing internal command " + str(int_cmd)) int_cmd.doIt(self) *************** *** 275,286 **** for int_cmd in cmdsToReadd: queue.put(int_cmd) ! pass # this is how we exit ! if not foundNonPyDBDaemonThread: self.finishDebuggingSession = True finally: self.release() def processNetCommand(self, id, seq, text): self.acquire() try: --- 291,314 ---- for int_cmd in cmdsToReadd: queue.put(int_cmd) ! # this is how we exit ! if not foundNonPyDBDaemonThread: self.finishDebuggingSession = True + + for tId in self.RUNNING_THREAD_IDS.keys(): + if tId not in foundThreads: + self.processThreadNotAlive(tId) + finally: self.release() def processNetCommand(self, id, seq, text): + '''Processes a command received from the Java side + + @param id: the id of the command + @param seq: the sequence of the command + @param text: the text received in the command + ''' + self.acquire() try: *************** *** 409,418 **** self.release() ! def processThreadNotAlive(self, thread): """ if thread is not alive, cancel trace_dispatch processing """ wasNotified = thread.additionalInfo.pydev_notify_kill if not wasNotified: ! cmd = self.cmdFactory.makeThreadKilledMessage(id(thread)) self.writer.addCommand(cmd) thread.additionalInfo.pydev_notify_kill = True --- 437,451 ---- self.release() ! def processThreadNotAlive(self, threadId): """ if thread is not alive, cancel trace_dispatch processing """ + thread = self.RUNNING_THREAD_IDS.get(threadId,None) + if thread is None: + return + + del self.RUNNING_THREAD_IDS[threadId] wasNotified = thread.additionalInfo.pydev_notify_kill if not wasNotified: ! cmd = self.cmdFactory.makeThreadKilledMessage(threadId) self.writer.addCommand(cmd) thread.additionalInfo.pydev_notify_kill = True *************** *** 493,497 **** # if thread is not alive, cancel trace_dispatch processing if not t.isAlive(): ! self.processThreadNotAlive(t) return None # suspend tracing --- 526,530 ---- # if thread is not alive, cancel trace_dispatch processing if not t.isAlive(): ! self.processThreadNotAlive(id(t)) return None # suspend tracing |