From fc5e80fea5e509ecc7ca416cf829f38d83aee40f Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 29 Apr 2026 18:13:46 -0400 Subject: [PATCH] Drop subint-family gate from `main_thread_forkserver` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `main_thread_forkserver` doesn't actually need py3.14 `concurrent.interpreters` (PEP 734) — it forks from a non-trio worker thread and runs `_trio_main` in the child, same shape as `trio_proc`. The previous `_has_subints` gate + subint-family `case` arm were a copy-paste error. In `tractor.spawn._main_thread_forkserver`, - drop the `_has_subints` import + the `RuntimeError` raise in `main_thread_forkserver_proc()`. - drop the now-unused `import sys` (only used by the prior error msg). In `tractor.spawn._spawn.try_set_start_method()`, - pull `'main_thread_forkserver'` out of the subint- family arm (which still gates on `_has_subints`). - merge it into the `'trio'` arm — both set `_ctx = None` bc neither needs an `mp.context`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/spawn/_main_thread_forkserver.py | 9 --------- tractor/spawn/_spawn.py | 6 ++++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/tractor/spawn/_main_thread_forkserver.py b/tractor/spawn/_main_thread_forkserver.py index ecb0de14..75c24197 100644 --- a/tractor/spawn/_main_thread_forkserver.py +++ b/tractor/spawn/_main_thread_forkserver.py @@ -346,7 +346,6 @@ from __future__ import annotations import errno import os import signal -import sys import threading from functools import partial from typing import ( @@ -370,7 +369,6 @@ from ._spawn import ( cancel_on_completion, soft_kill, ) -from ._subint import _has_subints if TYPE_CHECKING: from tractor.discovery._addr import UnwrappedAddress @@ -832,13 +830,6 @@ async def main_thread_forkserver_proc( thread instead of `trio.lowlevel.open_process()`. ''' - if not _has_subints: - raise RuntimeError( - f'The {"main_thread_forkserver"!r} spawn backend ' - f'requires Python 3.14+.\n' - f'Current runtime: {sys.version}' - ) - # Backend-scoped config pulled from `proc_kwargs`. Using # `proc_kwargs` (vs a first-class kwarg on this function) # matches how other backends expose per-spawn tuning diff --git a/tractor/spawn/_spawn.py b/tractor/spawn/_spawn.py index acad8485..c22eeb70 100644 --- a/tractor/spawn/_spawn.py +++ b/tractor/spawn/_spawn.py @@ -135,13 +135,15 @@ def try_set_start_method( case 'mp_spawn': _ctx = mp.get_context('spawn') - case 'trio': + case ( + 'trio' + | 'main_thread_forkserver' + ): _ctx = None case ( 'subint' | 'subint_fork' - | 'main_thread_forkserver' | 'subint_forkserver' ): # All subint-family backends need no `mp.context`;