tractor/ai/prompt-io/prompts/subints_spawner.md

35 lines
1.4 KiB
Markdown
Raw Normal View History

This is your first big boi, "from GH issue" design, plan and
implement task.
We need to try and add sub-interpreter (aka subint) support per the
issue,
https://github.com/goodboy/tractor/issues/379
Part of this work should include,
- modularizing and thus better organizing the `.spawn.*` subpkg by
breaking up various backends currently in `spawn._spawn` into
separate submods where it makes sense.
- add a new `._subint` backend which tries to keep as much of the
inter-process-isolation machinery in use as possible but with plans
to optimize for localhost only benefits as offered by python's
subints where possible.
* utilizing localhost-only tpts like UDS, shm-buffers for
performant IPC between subactors but also leveraging the benefits from
the traditional OS subprocs mem/storage-domain isolation, linux
namespaces where possible and as available/permitted by whatever
is happening under the hood with how cpython implements subints.
* default configuration should encourage state isolation as with
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) https://github.com/goodboy/tractor/pull/444#pullrequestreview-4165928469 (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
2026-04-23 22:30:11 +00:00
subprocs, but explicit public escape hatches to enable rigorously
managed shm channels for high performance apps.
- all tests should be (able to be) parameterized to use the new
`subints` backend and enabled by flag in the harness using the
existing `pytest --spawn-backend <spawn-backend>` support offered in
the `open_root_actor()` and `.testing._pytest` harness override
fixture.