From cbb3796a5f719afddc5d5d0c7034d9b029168226 Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 29 Nov 2026 19:09:39 -0500 Subject: [PATCH 1/2] docs: withdraw the claim that debugpy's log made the #1384 freeze frequent The changelog entry of the debugpy log change, and a comment beside it, said the in-program log made the multi-thread freeze far more likely: 6 freezes in 600 rounds with the log on, none in 600 with it off. The comparison does not show that. A freeze needs both threads at their breakpoints together, and with the log off the second thread ran only 1 and 3 times in those 600 rounds; with it on, it left its wait 33 times for the 6 freezes. Zero freezes in a handful of chances says nothing either way. What stands is the cost of a logpoint hit (26.1 to 11.7 microseconds), which is what that change was for. The entry, the comment and two doc references now say only that. Whether the log changes how often the freeze happens is open in #1384. The claim was the manager session's; so is this correction. The squash message of #1392 carries it too and cannot be changed. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs --- changelog.d/1264.fixed.md | 2 +- docs/python/README.md | 2 +- docs/troubleshooting.md | 2 +- packages/adapter-python/src/python-debug-adapter.ts | 7 +++---- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/changelog.d/1264.fixed.md b/changelog.d/1264.fixed.md index 6ff9bef2..6ada6796 100644 --- a/changelog.d/1264.fixed.md +++ b/changelog.d/1264.fixed.md @@ -1 +1 @@ -**A launched Python program no longer runs with debugpy's debug log on** — the adapter started debugpy with `DEBUGPY_LOG_DIR` set to the session's log directory for every launch, and debugpy then turns its debug log on inside the debugged program as well: pydevd writes a line for every message it sends, on the program's own threads. Measured on one machine, that log was more than half the cost of a logpoint hit (26.1 µs with it, 11.7 µs without), and it made a freeze far more likely when two threads reach breakpoints together (#1384: 6 freezes in 600 rounds with the log on, none in 600 with it off). The adapter no longer sets the variable, and the policy's fallback spawn no longer passes `--log-dir`. To get debugpy's logs, set `DEBUGPY_LOG_DIR` in the server's environment: it passes through. Attach is unchanged: an attached program logs the way it was started. The docs and the `set_breakpoint` description carry the new figures (#1264, #1384) +**A launched Python program no longer runs with debugpy's debug log on** — the adapter started debugpy with `DEBUGPY_LOG_DIR` set to the session's log directory for every launch, and debugpy then turns its debug log on inside the debugged program as well: pydevd writes a line for every message it sends, on the program's own threads. Measured on one machine, that log was more than half the cost of a logpoint hit (26.1 µs with it, 11.7 µs without). The adapter no longer sets the variable, and the policy's fallback spawn no longer passes `--log-dir`. To get debugpy's logs, set `DEBUGPY_LOG_DIR` in the server's environment: it passes through. Attach is unchanged: an attached program logs the way it was started. The docs and the `set_breakpoint` description carry the new figures (#1264) diff --git a/docs/python/README.md b/docs/python/README.md index debe75a6..1b0ab328 100644 --- a/docs/python/README.md +++ b/docs/python/README.md @@ -321,4 +321,4 @@ The launch passes `dapLaunchArgs.env` through the Python adapter to debugpy. mcp 4. The stack trace shows the call hierarchy that led to the current position 5. Expressions are evaluated against the current paused debug context (current frame when available), with the evaluation context defaulting to `'variables'` — reads and arithmetic are reliable, but verify a mutation such as `x = 5` with a follow-up evaluate before relying on it 6. Child processes are debug sessions by default: debugpy's sub-process debugging is on (the last step of [#1081](https://github.com/debugmcp/mcp-debugger/issues/1081)), so every Python child the program starts (`subprocess`, `multiprocessing`, pytest-xdist workers, an autoreloader, a script that shells out to Python) becomes a child debug session of its own: `list_debug_sessions` lists it with `parentSessionId` naming this session, it stops on the breakpoints set on this session before launch (re-sent to it before it runs), and it has its own `get_output` and `close_debug_session`; closing the parent closes its children first. A `wait_for_stop` on this session is a wait on the tree: it reports a child's stop with `sessionId` naming the child (inspect, step and continue with that id) and `children` listing every child session with its state; a child can still be waited on by its own id. Each child parks until it is adopted (about 110 ms from report to its first stop), is a session row, and counts against `DEBUG_MCP_MAX_CHILD_SESSIONS` (default 32 live children per tree; beyond it a child is released and runs undebugged). Opt out per launch with `dapLaunchArgs: { subProcess: false }` (the children run undebugged and the launch answer's warning says so), per attach target with `python -m debugpy --listen … --configure-subProcess false` (or `debugpy.configure(subProcess=False)` in code — the attach request's `subProcess` is inert), or server-wide with `DEBUG_MCP_MAX_CHILD_SESSIONS=0`. The design is [the session tree](../architecture/session-tree.md), built on the handshake measured in [spike-notes-subprocess.md](spike-notes-subprocess.md) -7. debugpy's own logs (`debugpy.*.log`) are off by default. To turn them on for launched sessions, set `DEBUGPY_LOG_DIR` to a directory in the server's environment (for an attach target, pass `--log-to ` or set `DEBUGPY_LOG_DIR` when starting the target). Either switch also turns pydevd's debug log on inside the debugged program, which slows it: leave them off unless you are diagnosing debugpy itself (issues #1264, #1384). +7. debugpy's own logs (`debugpy.*.log`) are off by default. To turn them on for launched sessions, set `DEBUGPY_LOG_DIR` to a directory in the server's environment (for an attach target, pass `--log-to ` or set `DEBUGPY_LOG_DIR` when starting the target). Either switch also turns pydevd's debug log on inside the debugged program, which slows it: leave them off unless you are diagnosing debugpy itself (issue #1264). diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 119c14f8..3eb8ebcd 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -354,7 +354,7 @@ default, or a `sessions/` directory beside your `--log-file` when you set one: dap-trace-.ndjson # only with DAP_TRACE=1 ``` -Some debug engines drop their own logs into that same run directory. Python's debugpy does not write its `debugpy.*.log` files by default: to turn them on for launched sessions, set `DEBUGPY_LOG_DIR` to a directory in the server's environment. Setting `DEBUGPY_LOG_DIR` also turns pydevd's debug log on inside the debugged program, which slows the program and should be left off unless you are diagnosing debugpy itself (issues #1264, #1384). +Some debug engines drop their own logs into that same run directory. Python's debugpy does not write its `debugpy.*.log` files by default: to turn them on for launched sessions, set `DEBUGPY_LOG_DIR` to a directory in the server's environment. Setting `DEBUGPY_LOG_DIR` also turns pydevd's debug log on inside the debugged program, which slows the program and should be left off unless you are diagnosing debugpy itself (issue #1264). The proxy log follows the server's `--log-level` / `DEBUG_MCP_LOG_LEVEL`, so raise it to `debug` before reproducing. The server logs the resolved base directory at startup diff --git a/packages/adapter-python/src/python-debug-adapter.ts b/packages/adapter-python/src/python-debug-adapter.ts index c9aaf1c0..b1e660d5 100644 --- a/packages/adapter-python/src/python-debug-adapter.ts +++ b/packages/adapter-python/src/python-debug-adapter.ts @@ -444,10 +444,9 @@ export class PythonDebugAdapter extends EventEmitter implements IDebugAdapter { ], env: { // DEBUGPY_LOG_DIR is not set here. debugpy also turns its debug log on - // inside the debugged program when it is set: that doubled the cost of a - // logpoint hit and made the freeze of #1384 far more likely (#1264). An - // operator who wants debugpy's logs sets it in the server's environment, - // and it passes through with the rest of process.env. + // inside the debugged program when it is set, which doubled the cost of + // a logpoint hit (#1264). An operator who wants debugpy's logs sets it in + // the server's environment, and it passes through with process.env. ...process.env, PYTHONUNBUFFERED: '1' // Ensure unbuffered output } From de1fd8e711e6839e507603d58c1d32be62971252 Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 29 Nov 2026 19:15:49 -0500 Subject: [PATCH 2/2] docs: the fifth reference to the withdrawn claim (#1397 review) A comment in the Python policy's fallback spawn still cited the freeze issue as a reason for dropping --log-dir. Found by the Gemini review of the previous commit. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs --- packages/shared/src/interfaces/adapter-policy-python.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/src/interfaces/adapter-policy-python.ts b/packages/shared/src/interfaces/adapter-policy-python.ts index 21f72ae5..41e13d10 100644 --- a/packages/shared/src/interfaces/adapter-policy-python.ts +++ b/packages/shared/src/interfaces/adapter-policy-python.ts @@ -506,7 +506,7 @@ export const PythonAdapterPolicy = { }; } - // Otherwise, build the debugpy command (no --log-dir: issues #1264, #1384) + // Otherwise, build the debugpy command (no --log-dir: issue #1264) const pythonPath = payload.executablePath || (process.platform === 'win32' ? 'python' : 'python3'); return {