From bfbeda01c827bc0a4c3d6c4e22ae04f7ae0ef6b5 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Mon, 7 Oct 2013 02:57:22 +0200 Subject: [PATCH] stoptrace method added (PY-4711, PY-4714). --- python/helpers/pydev/pydevd.py | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index b75d388bc80b..031d6a15b662 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -155,6 +155,13 @@ class PyDBCommandThread(PyDBDaemonThread): #PydevdLog(0, 'Finishing debug communication...(3)') +def killAllPydevThreads(): + threads = threadingEnumerate() + for t in threads: + if hasattr(t, 'doKillPydevThread'): + t.doKillPydevThread() + + #======================================================================================================================= # PyDBCheckAliveThread #======================================================================================================================= @@ -174,10 +181,7 @@ class PyDBCheckAliveThread(PyDBDaemonThread): try: pydev_log.debug("No alive threads, finishing debug session") self.pyDb.FinishDebuggingSession() - threads = threadingEnumerate() - for t in threads: - if hasattr(t, 'doKillPydevThread'): - t.doKillPydevThread() + killAllPydevThreads() except: traceback.print_exc() @@ -1351,6 +1355,36 @@ def _locked_settrace(host, stdoutToServer, stderrToServer, port, suspend, trace_ if suspend: debugger.setSuspend(t, CMD_SET_BREAK) +def stoptrace(): + global connected + if connected: + pydevd_tracing.RestoreSysSetTraceFunc() + sys.settrace(None) + try: + #not available in jython! + threading.settrace(None) # for all future threads + except: + pass + + try: + thread.start_new_thread = _original_start_new_thread + thread.start_new = _original_start_new_thread + except: + pass + + debugger = GetGlobalDebugger() + + if debugger: + debugger.trace_dispatch = None + + debugger.SetTraceForFrameAndParents(GetFrame(), False) + + debugger.exiting() + + killAllPydevThreads() + + connected = False + class Dispatcher(object): def __init__(self): self.port = None