Debugger doesn't stop on breakpoints in threads if "Gevent compatible" option is set in Python debugger settings (PY-18823)

Patch user's thread and threading modules and avoid deadlock while importing global debugger
This commit is contained in:
Elizaveta Shashkova
2016-03-31 20:03:58 +03:00
parent 2390269c3e
commit 4e9d5f9836
2 changed files with 13 additions and 7 deletions
@@ -45,9 +45,7 @@ def _on_forked_process():
pydevd.threadingCurrentThread().__pydevd_main_thread = True
pydevd.settrace_forked()
def _on_set_trace_for_new_thread():
from _pydevd_bundle.pydevd_comm import get_global_debugger
global_debugger = get_global_debugger()
def _on_set_trace_for_new_thread(global_debugger):
if global_debugger is not None:
global_debugger.SetTrace(global_debugger.trace_dispatch)
@@ -534,11 +532,15 @@ class _NewThreadStartupWithTrace:
self.original_func = original_func
self.args = args
self.kwargs = kwargs
self.global_debugger = self.get_debugger()
def get_debugger(self):
from _pydevd_bundle.pydevd_comm import get_global_debugger
return get_global_debugger()
def __call__(self):
_on_set_trace_for_new_thread()
from _pydevd_bundle.pydevd_comm import get_global_debugger
global_debugger = get_global_debugger()
_on_set_trace_for_new_thread(self.global_debugger)
global_debugger = self.global_debugger
if global_debugger is not None and global_debugger.thread_analyser is not None:
# we can detect start_new_thread only here
@@ -567,7 +569,10 @@ _UseNewThreadStartup = _NewThreadStartupWithTrace
def _get_threading_modules_to_patch():
threading_modules_to_patch = []
from _pydev_imps._pydev_saved_modules import thread as _thread
try:
import thread as _thread
except:
import _thread
threading_modules_to_patch.append(_thread)
return threading_modules_to_patch
+1
View File
@@ -844,6 +844,7 @@ class PyDB:
def patch_threads(self):
try:
# not available in jython!
import threading
threading.settrace(self.trace_dispatch) # for all future threads
except:
pass