Repository navigation
Done
Description
Environment data
- debugpy version: 1.8.21
- OS and version: macOS 15.7.9 (x64)
- Python version: CPython 3.12.3
- Using VS Code or Visual Studio: VS Code 1.130.0 (x64), commit 1b6a188127eeaf9194f945eb6eb89a657e93c54c
Actual behavior
- In a local Python attach session, the Debug toolbar shows a
Disconnectbutton. - Disconnecting ends the session and leaves the target running.
Expected behavior
- The attach toolbar should offer Stop as an alternative to Disconnect.
- Stop should terminate the attached Python process.
- Disconnect should leave it running.
Steps to reproduce:
- Open an empty folder in desktop VS Code with the Python Debugger extension enabled.
a. Setdebug.toolBarLocationtofloatingin workspace settings so it is easy to see the toolbar. - Save this as heartbeat.py.
import os
import time
from itertools import count
import debugpy
debugpy.listen(("127.0.0.1", 5678))
print(f"Ready to attach (PID {os.getpid()})", flush=True)
debugpy.wait_for_client()
for tick in count():
print(f"Heartbeat {tick} (PID {os.getpid()})", flush=True)
time.sleep(1)- Run the script from a terminal in that folder.
python3.12 -m venv .venv
.venv/bin/python -m pip install debugpy==1.8.21
.venv/bin/python -X frozen_modules=off heartbeat.py
- Wait for Ready to attach, select Attach to heartbeat in Run and Debug, and press F5. Wait for the script to start printing heartbeats.
- Observe that only
Disconnectis offered as an option. - Observe that the same PID keeps printing after Disconnect is clicked.
Screenshots
- The active attach session shows the Disconnect control at the right end of the debug toolbar (no Stop)
- After clicking Disconnect, the hearbeat keeps printing
Suggested Next Step
Diagnosis
VS Code's protocol uses supportTerminateDebuggee https://github.com/microsoft/vscode/blob/733a99842b0e0e14c3593dfab31fff2035478ba0/src/vs/workbench/contrib/debug/common/debugProtocol.d.ts#L1806
However, debugpy's adapter sends an extra s insupportsTerminateDebuggee
debugpy/src/debugpy/adapter/clients.py
Line 194 in 858b05c
| "supportsTerminateDebuggee": True, |
Suggested Solution
Change https://github.com/microsoft/debugpy/blob/v1.8.21/src/debugpy/adapter/clients.py#L194 to supportTerminateDebuggee.
Metadata
Metadata
Assignees
Labels
No labels
Activity