microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
41 stars 17 forks source link

Would it be OK to create a task to start a debugpy session and then use that task as a `preLaunchTask` in launch config #213

Closed balaji closed 1 month ago

balaji commented 4 months ago

What I really want to do:

What I did

#!/usr/bin/env bash
python -m debugpy --listen localhost:5678 --wait-for-client --log-to /tmp/debugpylogs example.py
    {
      "name": "Python Debugger: Remote Attach",
      "type": "debugpy",
      "request": "attach",
      "connect": {
        "host": "localhost",
        "port": 5678
      },
      "preLaunchTask": "python debug",
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}",
          "remoteRoot": "."
        }
      ]
    }

What happens:

The debug session works. Sometimes in the first attempt. Sometimes in the second attempt.

Debugging working in First attempt:

1

Debugging working in Second Attempt:

2

Logs:

First Attempt Success.zip Second Attempt Success.zip

Test Code:

source.zip

Question:

Why would it work sometimes in the first attempt itself and why would it work only in the second attempt?

paulacamargo25 commented 1 month ago

Thanks for your issue report, that depends on how vscode handles the attach, if the problem persists could you create an issue in the vscode repository? thank you