mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
IDEA-CR-61812: Fix issue when pydevd threads are been traced and print warning if it has happened
(cherry picked from commit 9dfb2b4c903c5fd3d6d903fc4f2171c3738667b9) GitOrigin-RevId: 7bf235aeb854030823162a3ba5a778e46f37c3b2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
345a40561e
commit
9629463526
@@ -212,6 +212,7 @@ class PyDBDaemonThread(threading.Thread):
|
||||
PyCore.Py.setSystemState(ss)
|
||||
|
||||
self._stop_trace()
|
||||
self._warn_pydevd_thread_is_traced()
|
||||
self._on_run()
|
||||
except:
|
||||
if sys is not None and traceback is not None:
|
||||
@@ -233,6 +234,10 @@ class PyDBDaemonThread(threading.Thread):
|
||||
if self.pydev_do_not_trace:
|
||||
pydevd_tracing.SetTrace(None) # no debugging on this thread
|
||||
|
||||
def _warn_pydevd_thread_is_traced(self):
|
||||
if sys.gettrace():
|
||||
pydevd_log(1, "The debugger thread '%s' is traced which may lead to debugging performance issues." % self.__class__.__name__)
|
||||
|
||||
|
||||
def mark_as_pydevd_daemon_thread(thread):
|
||||
thread.pydev_do_not_trace = True
|
||||
|
||||
@@ -73,24 +73,17 @@ def _internal_set_trace(tracing_func):
|
||||
|
||||
def SetTrace(tracing_func):
|
||||
if TracingFunctionHolder._original_tracing is None:
|
||||
#This may happen before replace_sys_set_trace_func is called.
|
||||
# This may happen before replace_sys_set_trace_func is called.
|
||||
sys.settrace(tracing_func)
|
||||
return
|
||||
|
||||
current_thread = threading.currentThread()
|
||||
do_not_trace_before = getattr(current_thread, 'pydev_do_not_trace', None)
|
||||
if do_not_trace_before:
|
||||
return
|
||||
|
||||
try:
|
||||
TracingFunctionHolder._lock.acquire()
|
||||
current_thread.pydev_do_not_trace = True # avoid settrace reentering
|
||||
TracingFunctionHolder._warn = False
|
||||
_internal_set_trace(tracing_func)
|
||||
TracingFunctionHolder._warn = True
|
||||
finally:
|
||||
TracingFunctionHolder._lock.release()
|
||||
current_thread.pydev_do_not_trace = do_not_trace_before
|
||||
|
||||
|
||||
def replace_sys_set_trace_func():
|
||||
@@ -98,6 +91,7 @@ def replace_sys_set_trace_func():
|
||||
TracingFunctionHolder._original_tracing = sys.settrace
|
||||
sys.settrace = _internal_set_trace
|
||||
|
||||
|
||||
def restore_sys_set_trace_func():
|
||||
if TracingFunctionHolder._original_tracing is not None:
|
||||
sys.settrace = TracingFunctionHolder._original_tracing
|
||||
|
||||
Reference in New Issue
Block a user