(session, target, cwd=None, wait=True)
| 163 | @_runner |
| 164 | @contextlib.contextmanager |
| 165 | def 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 = """ |
| 183 | import sys |
| 184 | import threading |
| 185 | import time |
| 186 | |
| 187 | while "debugpy" not in sys.modules: |
| 188 | time.sleep(0.1) |
| 189 | |
| 190 | from debuggee import scratchpad |
| 191 | |
| 192 | while "_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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…