microsoft/ptvsd

Remote Debugger Process Not Terminated Upon Debugger Restart

Anti-Distinctlyminty opened this issue · 7 comments

Environment data

  • VS Code version: 1.42.1
  • Extension version (available under the Extensions sidebar): 2020.2.63072
  • OS and version: Windows 10 Pro version 1909 build 19363.657 remotely connecting to Ubuntu version 18.04.2 LTS
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.6.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: flask_restful
  • Relevant/affected Python-related VS Code extensions and their versions: Remote Development 0.19.0
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info microsoft/vscode-python#3977): Language server
  • Value of the python.languageServer setting: -

Expected behaviour

Debugging a flask_restful application, when hitting the debugger's restart button (or hitting Ctrl+Shift+F5) the remote debugging process should be properly terminated, then restarted.

Actual behaviour

Developing remotely from Windows on Ubuntu I have noticed that the debugAdapter/main.js process is never terminated when performing a debug restart. If the debugger is stopped, the process appears to be terminated correctly.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - control'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'WebHostNotebook - control'
> conda --version
> pyenv root
> python3.7 -c "import sys;print(sys.executable)"
> python3.6 -c "import sys;print(sys.executable)"
> python3 -c "import sys;print(sys.executable)"
> python2 -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> /usr/bin/python3 -c "import sys;print(sys.executable)"
> conda info --json
Starting Microsoft Python language server.
> /usr/bin/python3 -c "import jupyter"
> /usr/bin/python3 -c "import jupyter"
> /usr/bin/python3 -c "import notebook"
> /usr/bin/python3 -c "import notebook"
> conda --version

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Note: Nothing is shown in the log on a debug restart. This is printed upon stopping:

log.ts:197   ERR timeout after 500 ms: Error: timeout after 500 ms
    at t.RawDebugSession.handleErrorResponse (file:///C:/Users/WORKSTATIONL/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2892:728)
    at file:///C:/Users/WORKSTATIONL/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2892:159
    at async t.RawDebugSession.shutdown (file:///C:/Users/WORKSTATIONL/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2890:248)
    at async R.terminate (file:///C:/Users/WORKSTATIONL/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:5552:511)

@Anti-Distinctlyminty Can you share your launch.json configuration for this?

@karthiknadig Here you go

        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "${workspaceRoot}/src/api/run_api.py",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "1"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload",
                "--host=0.0.0.0"
            ],
            "jinja": true
        }

And a quick sample of what I see when I list running processes containing the string 'python' by using ps -ef | grep python

myusername  7962  7369  0 Feb18 ?        00:00:00 /home/lukesapi/.vscode-server/bin/c47d83b293181d9be64f27ff093689e8e7aed054/node /home/lukesapi/.vscode-server/extensions/ms-python.python-2020.2.63072/out/client/debugger/debugAdapter/main.js
myusername 10179  7369  0 Feb18 ?        00:00:00 /home/lukesapi/.vscode-server/bin/c47d83b293181d9be64f27ff093689e8e7aed054/node /home/lukesapi/.vscode-server/extensions/ms-python.python-2020.2.63072/out/client/debugger/debugAdapter/main.js
myusername 10632     1  0 Feb17 ?        00:00:00 /home/lukesapi/.vscode-server/bin/c47d83b293181d9be64f27ff093689e8e7aed054/node /home/lukesapi/.vscode-server/extensions/ms-python.python-2020.2.63072/out/client/debugger/debugAdapter/main.js

This looks like it's using ptvsd 4. Can you try opting into the experiment to get you a newer version of ptvsd, and see if the issue still remains?

@int19h The instructions on the provided link are a little vague. I added the vsix file to my local windows .vscode/extensions folder, and added

"python.experiments.optInto": [
    "DebugAdapterFactory - experiment",
    "PtvsdWheels37 - experiment"
]

to my settings.json, but it become slightly greyed out and there's no "python.experiments.optInto" autocomplete so I'm almost certain I'm doing this incorrectly.

Sorry, it is indeed a bit confusing! You need to install the VSIX by using the "Extensions: install from VSIX" command. This is available in the command palette (Ctrl+Shift+P) - just type "VSIX" there, and you should see it.

Also, this is a global app-wide option, and thus it must go into the global settings.json - it won't work in the workspace one. If you have the right version of the extension, you should be able to do File -> Preferences -> Settings, select the User tab (if not already selected), and then search for "optInto" to find it.

After using the experimental debugger the problem seems to be resolved. Thank you.