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

Function spawn_debuggee

src/debugpy/adapter/launchers.py:68–217  ·  view source on GitHub ↗
(
    session,
    start_request,
    python,
    launcher_path,
    adapter_host,
    args,
    shell_expand_args,
    cwd,
    console,
    console_title,
    sudo,
)

Source from the content-addressed store, hash-verified

66
67
68def spawn_debuggee(
69 session,
70 start_request,
71 python,
72 launcher_path,
73 adapter_host,
74 args,
75 shell_expand_args,
76 cwd,
77 console,
78 console_title,
79 sudo,
80):
81 global listener
82
83 # -E tells sudo to propagate environment variables to the target process - this
84 # is necessary for launcher to get DEBUGPY_LAUNCHER_PORT and DEBUGPY_LOG_DIR.
85 cmdline = ["sudo", "-E"] if sudo else []
86 cmdline += python
87 cmdline += [launcher_path]
88 env = {}
89
90 arguments = dict(start_request.arguments)
91 if not session.no_debug:
92 _, arguments["port"] = sockets.get_address(servers.listener)
93 arguments["adapterAccessToken"] = adapter.access_token
94
95 def on_launcher_connected(sock):
96 listener.close()
97 stream = messaging.JsonIOStream.from_socket(sock)
98 Launcher(session, stream)
99
100 try:
101 listener = sockets.serve(
102 "Launcher", on_launcher_connected, adapter_host, backlog=1
103 )
104 except Exception as exc:
105 raise start_request.cant_handle(
106 "{0} couldn't create listener socket for launcher: {1}", session, exc
107 )
108 sessions.report_sockets()
109
110 try:
111 launcher_host, launcher_port = sockets.get_address(listener)
112 localhost = sockets.get_default_localhost()
113 launcher_addr = (
114 launcher_port
115 if launcher_host == localhost
116 else f"{launcher_host}:{launcher_port}"
117 )
118 cmdline += [str(launcher_addr), "--"]
119 cmdline += args
120
121 if log.log_dir is not None:
122 env[str("DEBUGPY_LOG_DIR")] = log.log_dir
123 if log.stderr.levels != {"warning", "error"}:
124 env[str("DEBUGPY_LOG_STDERR")] = str(" ".join(log.stderr.levels))
125

Callers

nothing calls this directly

Calls 13

get_addressMethod · 0.80
cant_handleMethod · 0.80
report_socketsMethod · 0.80
infoMethod · 0.80
itemsMethod · 0.80
requireMethod · 0.80
attach_to_sessionMethod · 0.80
joinMethod · 0.45
send_requestMethod · 0.45
propagateMethod · 0.45
wait_forMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…