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

Method spawn_debuggee

tests/debug/session.py:403–442  ·  view source on GitHub ↗
(self, args, cwd=None, exe=sys.executable, setup=None)

Source from the content-addressed store, hash-verified

401 return result
402
403 def spawn_debuggee(self, args, cwd=None, exe=sys.executable, setup=None):
404 assert self.debuggee is None
405 assert not len(self.captured_output - {"stdout", "stderr"})
406
407 args = self._make_python_cmdline(exe, *args)
408 cwd = cwd.strpath if isinstance(cwd, py.path.local) else cwd
409
410 env = self._make_env(self.spawn_debuggee.env, codecov=False)
411 self.adapter_endpoints = self.tmpdir / "adapter_endpoints"
412 env["DEBUGPY_ADAPTER_ENDPOINTS"] = self.adapter_endpoints.strpath
413 if setup is not None:
414 env["DEBUGPY_TEST_DEBUGGEE_SETUP"] = setup
415
416 log.info(
417 "Spawning {0}:\n\n"
418 "Current directory: {1}\n\n"
419 "Command line: {2}\n\n"
420 "Environment variables: {3}\n\n",
421 self.debuggee_id,
422 json.repr(cwd),
423 json.repr(args),
424 json.repr(env),
425 )
426
427 popen_fds = {}
428 capture_fds = {}
429 for stream_name in self.captured_output:
430 rfd, wfd = os.pipe()
431 popen_fds[stream_name] = wfd
432 capture_fds[stream_name] = rfd
433 self.debuggee = psutil.Popen(
434 args, cwd=cwd, env=env, bufsize=0, stdin=subprocess.PIPE, **popen_fds
435 )
436 log.info("Spawned {0} with PID={1}", self.debuggee_id, self.debuggee.pid)
437 watchdog.register_spawn(self.debuggee.pid, self.debuggee_id)
438
439 if len(capture_fds):
440 self.captured_output = output.CapturedOutput(self, **capture_fds)
441 for fd in popen_fds.values():
442 os.close(fd)
443
444 def wait_for_adapter_socket(self):
445 log.info(

Callers 8

run_in_terminalMethod · 0.95
launch_requestMethod · 0.80
attach_pidFunction · 0.80
attach_connectFunction · 0.80
spawn_debuggeeFunction · 0.80
test_attach_apiFunction · 0.80
test_cancel_waitFunction · 0.80

Calls 5

_make_python_cmdlineMethod · 0.95
_make_envMethod · 0.95
infoMethod · 0.80
valuesMethod · 0.80
closeMethod · 0.45

Tested by 3

test_attach_apiFunction · 0.64
test_cancel_waitFunction · 0.64