Skip to content

Commit 57dae0e

Browse files
committed
Split forkserver backend into variant 1/2 mods
The `subint_forkserver` name was always aspirational — today's impl forks from a regular main-interp worker thread and the child runs trio on its own main interp; NO subinterp anywhere in parent or child. Splitting the backend into two clearly-named variants drops the lie: - **variant 1** — `main_thread_forkserver` (the working impl). New `SpawnMethodKey` literal + `_methods` dispatch entry + `_runtime.Actor._from_parent()` match-arm. The spawn-coro `subint_forkserver_proc` moves to `_main_thread_forkserver` and is renamed `main_thread_forkserver_proc()`. - **variant 2** — `subint_forkserver` (future, reserved). Module shrinks to a placeholder describing the variant-2 design (subint-isolated child runtime, gated on jcrist/msgspec#1026 + PEP 684). Today the legacy `'subint_forkserver'` key aliases to `main_thread_forkserver_proc` so existing `--spawn-backend=subint_forkserver` invocations keep working; flipped to a `NotImplementedError` stub in a follow-up. Deats, - `Actor._from_parent()` spawn-method gate now accepts both `'main_thread_forkserver'` and `'subint_forkserver'` (both go through the IPC-`SpawnSpec` path). - the variant-1 spawn-coro stamps its own `SpawnSpec` / log lines with `spawn_method='main_thread_forkserver'` so subactor renders reflect the actual mechanism. - docstring reorg: trio×fork hazard breakdown, POSIX fork-survival semantics, in-process-vs-stdlib forkserver design notes, and the TODO/cleanup section all move from `_subint_forkserver` to `_main_thread_forkserver` (lives with the working code). `_subint_forkserver` keeps a tight forward- looking doc that motivates the reserved key. - `run_subint_in_worker_thread()` stays in `_subint_forkserver` as the companion primitive — it's the subint counterpart to `fork_from_worker_thread()` and will plug into the future variant-2 spawn-coro. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent 99dade0 commit 57dae0e

4 files changed

Lines changed: 672 additions & 634 deletions

File tree

tractor/runtime/_runtime.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -873,9 +873,12 @@ async def _from_parent(
873873
if self._spawn_method in (
874874
'trio',
875875
'subint',
876-
# `subint_forkserver` parent-side sends a
877-
# `SpawnSpec` over IPC just like the other two
878-
# — fork child-side runtime is trio-native.
876+
# `main_thread_forkserver` (and the future
877+
# variant-2 `subint_forkserver`) parent-side
878+
# sends a `SpawnSpec` over IPC just like the
879+
# other two — fork child-side runtime is
880+
# trio-native.
881+
'main_thread_forkserver',
879882
'subint_forkserver',
880883
):
881884

0 commit comments

Comments
 (0)