MCPcopy Create free account
hub / github.com/microsoft/debugpy / attach_pid

Function attach_pid

tests/debug/runners.py:165–207  ·  view source on GitHub ↗
(session, target, cwd=None, wait=True)

Source from the content-addressed store, hash-verified

163@_runner
164@contextlib.contextmanager
165def attach_pid(session, target, cwd=None, wait=True):
166 if wait and not sys.platform.startswith("linux"):
167 pytest.skip("https://github.com/microsoft/ptvsd/issues/1926")
168
169 log.info("Attaching {0} to {1} by PID.", session, target)
170
171 config = session.config
172 try:
173 config["processId"] = int(target)
174 except TypeError:
175 pass
176
177 if "processId" not in config:
178 _attach_common_config(session, target, cwd)
179 args = target.cli(session.spawn_debuggee.env)
180
181 if wait:
182 debuggee_setup = """
183import sys
184import threading
185import time
186
187while "debugpy" not in sys.modules:
188 time.sleep(0.1)
189
190from debuggee import scratchpad
191
192while "_attach_pid" not in scratchpad:
193 time.sleep(0.1)
194 """
195 else:
196 debuggee_setup = None
197
198 session.spawn_debuggee(args, cwd=cwd, setup=debuggee_setup)
199 config["processId"] = session.debuggee.pid
200
201 session.spawn_adapter()
202 session.expect_server_socket()
203 with session.request_attach():
204 yield
205
206 if wait:
207 session.scratchpad["_attach_pid"] = True
208
209
210@_runner

Callers

nothing calls this directly

Calls 7

_attach_common_configFunction · 0.85
infoMethod · 0.80
spawn_debuggeeMethod · 0.80
spawn_adapterMethod · 0.80
expect_server_socketMethod · 0.80
request_attachMethod · 0.80
cliMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…