| 317 | |
| 318 | |
| 319 | def start_debugging(argv_0): |
| 320 | # We need to set up sys.argv[0] before invoking either listen() or connect(), |
| 321 | # because they use it to report the "process" event. Thus, we can't rely on |
| 322 | # run_path() and run_module() doing that, even though they will eventually. |
| 323 | sys.argv[0] = argv_0 |
| 324 | |
| 325 | log.debug("sys.argv after patching: {0!r}", sys.argv) |
| 326 | |
| 327 | debugpy.configure(options.config) |
| 328 | |
| 329 | if os.environ.get("DEBUGPY_RUNNING", "false") != "true": |
| 330 | if options.mode == "listen" and options.address is not None: |
| 331 | debugpy.listen(options.address) |
| 332 | elif options.mode == "connect" and options.address is not None: |
| 333 | debugpy.connect(options.address, access_token=options.adapter_access_token, parent_session_pid=options.parent_session_pid) |
| 334 | else: |
| 335 | raise AssertionError(repr(options.mode)) |
| 336 | |
| 337 | if options.wait_for_client: |
| 338 | debugpy.wait_for_client() |
| 339 | |
| 340 | os.environ["DEBUGPY_RUNNING"] = "true" |
| 341 | |
| 342 | |
| 343 | def run_file(): |