Skip to content

Commit 205382a

Browse files
committed
Sweep subint_forkservermain_thread_forkserver in code
After the variant-1 / variant-2 backend split, update remaining string-match refs to the variant-1 backend so user-visible gates + skip-marks + comments name the working backend correctly: - `tractor._root._DEBUG_COMPATIBLE_BACKENDS`: include `main_thread_forkserver`, drop the stub-only `subint_forkserver` entry. - `tests/test_spawning.py::test_loglevel_propagated_to_subactor`: capfd-skip flips to `main_thread_forkserver`. - `tests/test_infected_asyncio.py::test_sigint_closes_lifetime_stack`: xfail-condition flips to `main_thread_forkserver`. - `tests/test_shm.py`: drop stale "broken on `main_thread_forkserver`" reason-text since the `mp.SharedMemory(track=False)` + resource-tracker monkey-patch in `.ipc._mp_bs` makes the tests pass; the skip-mark only fires on plain `subint` now. - Comment / docstring sweep: `runtime._state`, `runtime._runtime`, `_testing.pytest`, `_subint.py`, `pyproject.toml`, `test_cancellation.py`, `test_registrar.py` — refs to variant-1 backend updated. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent 9f0709e commit 205382a

11 files changed

Lines changed: 28 additions & 29 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ addopts = [
217217
'--show-capture=no',
218218

219219
# sys-level capture. REQUIRED for fork-based spawn
220-
# backends (e.g. `subint_forkserver`): default
220+
# backends (e.g. `main_thread_forkserver`): default
221221
# `--capture=fd` redirects fd 1,2 to temp files, and fork
222222
# children inherit those fds — opaque deadlocks happen in
223223
# the pytest-capture-machinery ↔ fork-child stdio

tests/discovery/test_registrar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,13 @@ async def kill_transport(
538538
@pytest.mark.timeout(
539539
30,
540540
# NOTE should be a 2.1s happy path.
541-
# XXX for `subint_forkserver` this is SUPER SENSITIVE so keep it
542-
# higher to avoid flaky runs..
541+
# XXX for `main_thread_forkserver` this is SUPER SENSITIVE
542+
# so keep it higher to avoid flaky runs..
543543
method='thread',
544544
)
545545
@pytest.mark.skipon_spawn_backend(
546546
'subint',
547-
# 'subint_forkserver',
547+
# 'main_thread_forkserver',
548548
reason=(
549549
'XXX SUBINT HANGING TEST XXX\n'
550550
'See oustanding issue(s)\n'

tests/test_cancellation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,12 @@ async def spawn_and_error(
452452
await nursery.run_in_actor(*args, **kwargs)
453453

454454

455-
# NOTE: subint_forkserver skip handled by file-level `pytestmark`
456-
# above (same pytest-capture-fd hang class as siblings).
455+
# NOTE: `main_thread_forkserver` capture-fd hang class is no
456+
# longer skipped here — `--capture=sys` (the new `pyproject.toml`
457+
# default) sidesteps the pipe-buffer-fill deadlock for
458+
# `test_nested_multierrors`. See
459+
# `ai/conc-anal/subint_forkserver_test_cancellation_leak_issue.md`
460+
# / #449 for the post-mortem.
457461
@pytest.mark.timeout(
458462
10,
459463
method='thread',

tests/test_infected_asyncio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ async def main():
11131113
if (
11141114
send_sigint_to == 'child'
11151115
and
1116-
start_method == 'subint_forkserver'
1116+
start_method == 'main_thread_forkserver'
11171117
):
11181118
pytest.xfail(
11191119
reason=(

tests/test_shm.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,16 @@
1616

1717
pytestmark = pytest.mark.skipon_spawn_backend(
1818
'subint',
19-
# 'subint_forkserver',
20-
# XXX we hack around this stdlib limitation by both,
21-
# - setting `ShareMemory(track=False)`
22-
# - overriding the `mp.ResourceTracker` nonsense in
23-
# `.ipc._mp_bs`.
19+
# NOTE, `main_thread_forkserver` works for these tests
20+
# via the `mp.SharedMemory(track=False)` +
21+
# `mp.resource_tracker` monkey-patch in `.ipc._mp_bs`.
22+
# Without that workaround the fork-inherited
23+
# `resource_tracker` fd would EBADF on first shm op +
24+
# cascade into `FileExistsError` across parametrize
25+
# variants. Tracker doc:
26+
# `ai/conc-anal/subint_forkserver_mp_shared_memory_issue.md`.
2427
reason=(
2528
'subint: GIL-contention hanging class.\n'
26-
'subint_forkserver: `multiprocessing.SharedMemory` '
27-
'is fork-without-exec unsafe — child inherits parent\'s '
28-
'`resource_tracker` fd → EBADF on first shm op '
29-
'(`test_child_attaches_alot`); leaked `/shm_list` from '
30-
'a "passing" run cascades into `FileExistsError` across '
31-
'parametrize variants (`test_parent_writer_child_reader`). '
32-
'Canonical CPython issue class, NOT a tractor bug; full '
33-
'tracker doc:\n'
34-
'ai/conc-anal/subint_forkserver_mp_shared_memory_issue.md'
3529
)
3630
)
3731

tests/test_spawning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_loglevel_propagated_to_subactor(
194194
reg_addr: tuple,
195195
level: str,
196196
):
197-
if start_method in ('mp_forkserver', 'subint_forkserver'):
197+
if start_method in ('mp_forkserver', 'main_thread_forkserver'):
198198
pytest.skip(
199199
"a bug with `capfd` seems to make forkserver capture not work? "
200200
"(same class as the `mp_forkserver` pre-existing skip — fork-"

tractor/_root.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
'trio',
8080
# forkserver children run `_trio_main` in their own OS
8181
# process — same child-side runtime shape as `trio_proc`.
82-
'subint_forkserver',
82+
'main_thread_forkserver',
8383
)
8484

8585

tractor/_testing/pytest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def _reap_orphaned_subactors():
303303
grace window, then SIGKILL survivors.
304304
305305
Rationale: under fork-based spawn backends (notably
306-
`subint_forkserver`), a test that times out or bails
306+
`main_thread_forkserver`), a test that times out or bails
307307
mid-teardown can leave subactor forks alive. Without
308308
this reap, they linger across sessions and compete
309309
for ports / inherit pytest's capture-pipe fds — which

tractor/runtime/_runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ async def async_main(
17631763
# shielded loop would park on the parent chan
17641764
# indefinitely waiting for EOF that only arrives
17651765
# after the PARENT tears down, which under
1766-
# fork-based backends (e.g. `subint_forkserver`)
1766+
# fork-based backends (e.g. `main_thread_forkserver`)
17671767
# it waits on THIS actor's exit — deadlock.
17681768
actor._parent_chan_cs = await root_tn.start(
17691769
partial(

tractor/runtime/_state.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ def update(
122122
# `open_root_actor()` nor received a parent `SpawnSpec`. Kept
123123
# as a module-level constant so `get_runtime_vars(clear_values=
124124
# True)` can reset the live dict back to this baseline (see
125-
# `tractor.spawn._subint_forkserver` for the one current caller
126-
# that needs it).
125+
# `tractor.spawn._main_thread_forkserver` for the one current
126+
# caller that needs it).
127127
_RUNTIME_VARS_DEFAULTS: dict[str, Any] = {
128128
# root of actor-process tree info
129129
'_is_root': False, # bool
@@ -165,7 +165,7 @@ def get_runtime_vars(
165165
defaults (`_RUNTIME_VARS_DEFAULTS`) instead of the live
166166
dict. Useful in combination with `set_runtime_vars()` to
167167
reset process-global state back to "cold" — the main caller
168-
today is the `subint_forkserver` spawn backend's post-fork
168+
today is the `main_thread_forkserver` spawn backend's post-fork
169169
child prelude:
170170
171171
set_runtime_vars(get_runtime_vars(clear_values=True))

0 commit comments

Comments
 (0)