Skip to content

Commit 10d8839

Browse files
committed
Review feedback
1 parent 83ff280 commit 10d8839

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

src/debugpy/common/messaging.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import threading
2222

2323
from debugpy.common import json, log, util
24-
from debugpy.common.util import skip_trace
24+
from debugpy.common.util import hide_thread_from_debugger
2525

2626

2727
class JsonIOError(IOError):
@@ -1150,10 +1150,8 @@ def start(self):
11501150
target=self._parse_incoming_messages, name=f"{self} message parser"
11511151
)
11521152

1153-
if skip_trace():
1154-
self._parser_thread.pydev_do_not_trace = True
1155-
self._parser_thread.is_pydev_daemon_thread = True
1156-
self._parser_thread.daemon = True
1153+
hide_thread_from_debugger(self._parser_thread)
1154+
self._parser_thread.daemon = True
11571155
self._parser_thread.start()
11581156

11591157
def wait(self):

src/debugpy/common/sockets.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import threading
88

99
from debugpy.common import log
10-
from debugpy.common.util import skip_trace
10+
from debugpy.common.util import hide_thread_from_debugger
1111

1212

1313
def create_server(host, port=0, backlog=socket.SOMAXCONN, timeout=None):
@@ -115,10 +115,8 @@ def accept_worker():
115115
handler(sock)
116116

117117
thread = threading.Thread(target=accept_worker)
118-
if skip_trace():
119-
thread.daemon = True
120-
thread.pydev_do_not_trace = True
121-
thread.is_pydev_daemon_thread = True
118+
thread.daemon = True
119+
hide_thread_from_debugger(thread)
122120
thread.start()
123121

124122
return listener

src/debugpy/common/util.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,15 @@ def srcnameof(obj):
150150
return name
151151

152152

153-
def skip_trace():
154-
"""Returns True if tracing should be skipped for the current thread."""
153+
def hide_debugpy_internals():
154+
"""Returns True if the caller should hide something from debugpy."""
155155
return "DEBUGPY_TRACE_DEBUGPY" not in os.environ
156156

157157

158-
def disable_tracing(thread):
158+
def hide_thread_from_debugger(thread):
159159
"""Disables tracing for the given thread if DEBUGPY_TRACE_DEBUGPY is not set.
160160
DEBUGPY_TRACE_DEBUGPY is used to debug debugpy with debugpy
161161
"""
162-
if skip_trace():
162+
if hide_debugpy_internals():
163163
thread.pydev_do_not_trace = True
164164
thread.is_pydev_daemon_thread = True
165-
thread.daemon = True

src/debugpy/server/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from debugpy.common import json, log, sockets
1515
from _pydevd_bundle.pydevd_constants import get_global_debugger
1616
from pydevd_file_utils import absolute_path
17-
from debugpy.common.util import skip_trace
17+
from debugpy.common.util import hide_debugpy_internals
1818

1919
_tls = threading.local()
2020

@@ -129,7 +129,7 @@ def debug(address, **kwargs):
129129
"patch_multiprocessing": _config.get("subProcess", True),
130130
}
131131

132-
if skip_trace():
132+
if hide_debugpy_internals():
133133
debugpy_path = os.path.dirname(absolute_path(debugpy.__file__))
134134
settrace_kwargs["dont_trace_start_patterns"] = (debugpy_path,)
135135
settrace_kwargs["dont_trace_end_patterns"] = (str("debugpy_launcher.py"),)

0 commit comments

Comments
 (0)