Skip to content

Commit a7b1ee3

Browse files
committed
Restore fn-arg _runtime_vars in trio_proc teardown
During the Phase A extraction of `trio_proc()` out of `spawn._spawn` into its own submod, the `debug.maybe_wait_for_debugger(child_in_debug=...)` call site in the hard-reap `finally` got refactored from the original `_runtime_vars.get('_debug_mode', ...)` (the fn parameter — the dict that was constructed by the *parent* for the *child*'s `SpawnSpec`) to `get_runtime_vars().get(...)` (a global getter that returns the *parent's* live `_state`). Those are semantically different — the first asks "is the child we just spawned in debug mode?", the second asks "are *we* in debug mode?". Under mixed-debug-mode trees the swap can incorrectly skip (or unnecessarily delay) the debugger-lock wait during teardown. Revert to the fn-parameter lookup and add an inline `NOTE` comment calling out the distinction so it's harder to regress again. Deats, - `spawn/_trio.py`: `child_in_debug=get_runtime_vars().get(...)` → `child_in_debug=_runtime_vars.get(...)` at the `debug.maybe_wait_for_debugger(...)` call in the hard-reap block; add 4-line `NOTE` explaining the parent-vs-child distinction. - `spawn/__init__.py`: drop trailing whitespace after the `'mp_forkserver'` docstring bullet. - `ai/prompt-io/prompts/subints_spawner.md`: drop duplicated `with` in `"as with with subprocs"` prose (copilot grammar catch). Review: PR #444 (Copilot) #444 (review) (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent ae5b63c commit a7b1ee3

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

ai/prompt-io/prompts/subints_spawner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Part of this work should include,
2424
is happening under the hood with how cpython implements subints.
2525

2626
* default configuration should encourage state isolation as with
27-
with subprocs, but explicit public escape hatches to enable rigorously
27+
subprocs, but explicit public escape hatches to enable rigorously
2828
managed shm channels for high performance apps.
2929

3030
- all tests should be (able to be) parameterized to use the new

tractor/spawn/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
- `._mp`: the stdlib `multiprocessing` backend variants — driven by
3030
the `mp.context` bound to `_spawn._ctx`:
3131
* `'mp_spawn'`,
32-
* `'mp_forkserver'`
32+
* `'mp_forkserver'`
3333
3434
Entry-point helpers live in `._entry`/`._mp_fixup_main`/
3535
`._forkserver_override`.

tractor/spawn/_trio.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,11 @@ async def trio_proc(
246246
await proc.wait()
247247

248248
await debug.maybe_wait_for_debugger(
249-
child_in_debug=get_runtime_vars().get(
249+
# NOTE: use the child's `_runtime_vars`
250+
# (the fn-arg dict shipped via `SpawnSpec`)
251+
# — NOT `get_runtime_vars()` which returns
252+
# the *parent's* live runtime state.
253+
child_in_debug=_runtime_vars.get(
250254
'_debug_mode', False
251255
),
252256
header_msg=(

0 commit comments

Comments
 (0)