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

Function test_breakaway_job

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

Source from the content-addressed store, hash-verified

504 sys.platform != "win32", reason="job objects are specific to Windows"
505)
506def test_breakaway_job(pyfile, target, run):
507 @pyfile
508 def child():
509 import os
510 from debuggee import backchannel
511
512 backchannel.send(os.getpid())
513 backchannel.receive()
514 backchannel.send("ok")
515
516 @pyfile
517 def parent():
518 import debuggee
519 import os
520 import subprocess
521 import sys
522
523 debuggee.setup()
524 argv = [sys.executable, sys.argv[1]]
525 env = os.environ.copy()
526 pipe_in = open(os.devnull, "r")
527 pipe_out = open(os.devnull, "w")
528 CREATE_BREAKAWAY_FROM_JOB = 0x01000000
529 proc = subprocess.Popen(
530 argv,
531 env=env,
532 stdin=pipe_in,
533 stdout=pipe_out,
534 stderr=pipe_out,
535 creationflags=CREATE_BREAKAWAY_FROM_JOB,
536 )
537 pipe_in.close()
538 pipe_out.close()
539 proc.wait()
540
541 with debug.Session() as parent_session:
542 parent_session.config.update(
543 {
544 "redirectOutput": False,
545 "subProcess": False,
546 }
547 )
548 parent_session.expected_exit_code = some.int
549 backchannel = parent_session.open_backchannel()
550
551 with run(parent_session, target(parent, args=[child])):
552 pass
553
554 child_pid = backchannel.receive()
555 child_process = psutil.Process(child_pid)
556
557 parent_session.request("terminate")
558 parent_session.wait_for_exit()
559
560 # child should still be running
561 backchannel.send("proceed")
562 assert backchannel.receive() == "ok"
563

Callers

nothing calls this directly

Calls 10

waitMethod · 0.95
open_backchannelMethod · 0.80
receiveMethod · 0.80
wait_for_exitMethod · 0.80
infoMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
updateMethod · 0.45
requestMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…