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

Function test_autokill

tests/debugpy/test_multiproc.py:250–300  ·  view source on GitHub ↗
(pyfile, target, run)

Source from the content-addressed store, hash-verified

248
249@pytest.mark.parametrize("run", runners.all_launch)
250def test_autokill(pyfile, target, run):
251 @pyfile
252 def child():
253 import os
254 from debuggee import backchannel
255
256 backchannel.send(os.getpid())
257 while True:
258 pass
259
260 @pyfile
261 def parent():
262 import debuggee
263 import os
264 import subprocess
265 import sys
266
267 debuggee.setup()
268 argv = [sys.executable, sys.argv[1]]
269 env = os.environ.copy()
270 subprocess.Popen(
271 argv,
272 env=env,
273 stdin=subprocess.PIPE,
274 stdout=subprocess.PIPE,
275 stderr=subprocess.PIPE,
276 ).wait()
277
278 with debug.Session() as parent_session:
279 parent_session.expected_exit_code = some.int
280
281 backchannel = parent_session.open_backchannel()
282 with run(parent_session, target(parent, args=[child])):
283 pass
284
285 child_config = parent_session.wait_for_next_event("debugpyAttach")
286 parent_session.proceed()
287
288 with debug.Session(child_config) as child_session:
289 with child_session.start():
290 pass
291
292 child_pid = backchannel.receive()
293 assert child_config["subProcessId"] == child_pid
294 child_process = psutil.Process(child_pid)
295
296 parent_session.request("terminate")
297 child_session.wait_for_exit()
298
299 log.info("Waiting for child process...")
300 child_process.wait()
301
302
303@pytest.mark.parametrize("run", runners.all_launch)

Callers

nothing calls this directly

Calls 11

waitMethod · 0.95
open_backchannelMethod · 0.80
wait_for_next_eventMethod · 0.80
proceedMethod · 0.80
receiveMethod · 0.80
wait_for_exitMethod · 0.80
infoMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
startMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…