11'''
2- Integration exercises for the `tractor.spawn._subint_forkserver `
2+ Integration exercises for the `tractor.spawn._main_thread_forkserver `
33submodule at three tiers:
44
551. the low-level primitives
6- (`fork_from_worker_thread()` +
7- `run_subint_in_worker_thread()`) driven from inside a real
6+ (`fork_from_worker_thread()` from `_main_thread_forkserver`
7+ + `run_subint_in_worker_thread()` from
8+ `_subint_forkserver`) driven from inside a real
89 `trio.run()` in the parent process,
910
10- 2. the full `subint_forkserver_proc ` spawn backend wired
11+ 2. the full `main_thread_forkserver_proc ` spawn backend wired
1112 through tractor's normal actor-nursery + portal-RPC
1213 machinery — i.e. `open_root_actor` + `open_nursery` +
1314 `run_in_actor` against a subactor spawned via fork from a
2728in the *parent*. Tiers (1)+(2) here cover the primitives
2829driven from inside `trio.run()` in the parent, and tier (3)
2930(the `*_spawn_basic` test) drives the registered
30- `subint_forkserver ` spawn backend end-to-end against the
31- tractor runtime.
31+ `main_thread_forkserver ` spawn backend end-to-end against
32+ the tractor runtime.
3233
3334Gating
3435------
3536- py3.14+ (via `concurrent.interpreters` presence)
3637- no `--spawn-backend` restriction — the backend-level test
3738 flips `tractor.spawn._spawn._spawn_method` programmatically
38- (via `try_set_start_method('subint_forkserver ')`) and
39+ (via `try_set_start_method('main_thread_forkserver ')`) and
3940 restores it on teardown, so these tests are independent of
4041 the session-level CLI backend choice.
4142
6465# `tractor.spawn._subint` for why.
6566pytest .importorskip ('concurrent.interpreters' )
6667
67- from tractor .spawn ._subint_forkserver import ( # noqa: E402
68+ from tractor .spawn ._main_thread_forkserver import ( # noqa: E402
6869 fork_from_worker_thread ,
69- run_subint_in_worker_thread ,
7070 wait_child ,
7171)
72+ from tractor .spawn ._subint_forkserver import ( # noqa: E402
73+ run_subint_in_worker_thread ,
74+ )
7275from tractor .spawn import _spawn as _spawn_mod # noqa: E402
7376from tractor .spawn ._spawn import try_set_start_method # noqa: E402
7477
@@ -195,7 +198,7 @@ def test_fork_from_worker_thread_via_trio(
195198 deadline : float = 10.0
196199 with dump_on_hang (
197200 seconds = deadline ,
198- path = '/tmp/subint_forkserver_baseline .dump' ,
201+ path = '/tmp/main_thread_forkserver_baseline .dump' ,
199202 ):
200203 pid : int = trio .run (
201204 partial (run_fork_in_non_trio_thread , deadline ),
@@ -217,14 +220,14 @@ def test_fork_and_run_trio_in_child() -> None:
217220 `trio.run()` inside it on yet another worker thread.
218221
219222 This is the full "forkserver + trio-in-subint-in-child"
220- pattern the proposed `subint_forkserver ` spawn backend
223+ pattern the proposed `main_thread_forkserver ` spawn backend
221224 would rest on.
222225
223226 '''
224227 deadline : float = 15.0
225228 with dump_on_hang (
226229 seconds = deadline ,
227- path = '/tmp/subint_forkserver_trio_in_child .dump' ,
230+ path = '/tmp/main_thread_forkserver_trio_in_child .dump' ,
228231 ):
229232 pid : int = trio .run (
230233 partial (
@@ -237,7 +240,7 @@ def test_fork_and_run_trio_in_child() -> None:
237240
238241
239242# ----------------------------------------------------------------
240- # tier-3 backend test: drive the registered `subint_forkserver `
243+ # tier-3 backend test: drive the registered `main_thread_forkserver `
241244# spawn backend end-to-end through tractor's actor-nursery +
242245# portal-RPC machinery.
243246# ----------------------------------------------------------------
@@ -260,7 +263,7 @@ async def _happy_path_forkserver(
260263 Parent-side harness: stand up a root actor, open an actor
261264 nursery, spawn one subactor via the currently-selected
262265 spawn backend (which this test will have flipped to
263- `subint_forkserver `), run a trivial RPC through its
266+ `main_thread_forkserver `), run a trivial RPC through its
264267 portal, assert the round-trip result.
265268
266269 '''
@@ -304,19 +307,19 @@ def forkserver_spawn_method():
304307
305308
306309@pytest .mark .timeout (60 , method = 'thread' )
307- def test_subint_forkserver_spawn_basic (
310+ def test_main_thread_forkserver_spawn_basic (
308311 reg_addr : tuple [str , int | str ],
309312 forkserver_spawn_method ,
310313) -> None :
311314 '''
312315 Happy-path: spawn ONE subactor via the
313- `subint_forkserver ` backend (parent-side fork from a
316+ `main_thread_forkserver ` backend (parent-side fork from a
314317 main-interp worker thread), do a trivial portal-RPC
315318 round-trip, tear the nursery down cleanly.
316319
317320 If this passes, the "forkserver + tractor runtime" arch
318321 is proven end-to-end: the registered
319- `subint_forkserver_proc ` spawn target successfully
322+ `main_thread_forkserver_proc ` spawn target successfully
320323 forks a child, the child runs `_actor_child_main()` +
321324 completes IPC handshake + serves an RPC, and the parent
322325 reaps via `_ForkedProc.wait()` without regressing any of
@@ -326,7 +329,7 @@ def test_subint_forkserver_spawn_basic(
326329 deadline : float = 20.0
327330 with dump_on_hang (
328331 seconds = deadline ,
329- path = '/tmp/subint_forkserver_spawn_basic .dump' ,
332+ path = '/tmp/main_thread_forkserver_spawn_basic .dump' ,
330333 ):
331334 trio .run (
332335 partial (
@@ -340,7 +343,7 @@ def test_subint_forkserver_spawn_basic(
340343# ----------------------------------------------------------------
341344# tier-4 DRAFT: orphaned-subactor SIGINT survivability
342345#
343- # Motivating question: with `subint_forkserver `, the child's
346+ # Motivating question: with `main_thread_forkserver `, the child's
344347# `trio.run()` lives on the fork-inherited worker thread which
345348# is NOT `threading.main_thread()` — so trio cannot install its
346349# `signal.set_wakeup_fd`-based SIGINT handler. If the parent
@@ -360,7 +363,7 @@ def test_subint_forkserver_spawn_basic(
360363# Cross-backend generalization (decide after this passes):
361364# - applicable to any backend whose subactors are separate OS
362365# processes: `trio`, `mp_spawn`, `mp_forkserver`,
363- # `subint_forkserver `.
366+ # `main_thread_forkserver `.
364367# - NOT applicable to plain `subint` (subactors are in-process
365368# subinterpreters, no orphan child process to SIGINT).
366369# - move path: lift the harness script into
@@ -446,7 +449,7 @@ def _process_alive(pid: int) -> bool:
446449 return False
447450
448451
449- # Known-gap test — `subint_forkserver ` orphan-SIGINT
452+ # Known-gap test — `main_thread_forkserver ` orphan-SIGINT
450453# handling. See
451454# `ai/conc-anal/subint_forkserver_orphan_sigint_hang_issue.md`.
452455# `strict=True` so if a future fix closes the gap the
@@ -471,12 +474,12 @@ def test_orphaned_subactor_sigint_cleanup_DRAFT(
471474) -> None :
472475 '''
473476 DRAFT — orphaned-subactor SIGINT survivability under the
474- `subint_forkserver ` backend.
477+ `main_thread_forkserver ` backend.
475478
476479 Sequence:
477480 1. Spawn a harness subprocess that brings up a root
478481 actor + one `sleep_forever` subactor via
479- `subint_forkserver `.
482+ `main_thread_forkserver `.
480483 2. Read the harness's stdout for `PARENT_READY=<pid>`
481484 and `CHILD_PID=<pid>` markers (confirms the
482485 parent→child IPC handshake completed).
@@ -524,7 +527,7 @@ def test_orphaned_subactor_sigint_cleanup_DRAFT(
524527 [
525528 sys .executable ,
526529 str (script_path ),
527- 'subint_forkserver ' ,
530+ 'main_thread_forkserver ' ,
528531 host ,
529532 str (port ),
530533 ],
@@ -577,7 +580,7 @@ def test_orphaned_subactor_sigint_cleanup_DRAFT(
577580
578581 pytest .fail (
579582 f'Orphan subactor (pid={ child_pid } ) did NOT exit '
580- f'within 10s of SIGINT under `subint_forkserver ` '
583+ f'within 10s of SIGINT under `main_thread_forkserver ` '
581584 f'→ trio on non-main thread did not observe the '
582585 f'default CPython KeyboardInterrupt; backend needs '
583586 f'explicit SIGINT plumbing.'
0 commit comments