Skip to content

Commit 1af2121

Browse files
committed
Wire reg_addr through leaky cancel tests
Stopgap companion to d012196 (`subint_forkserver` test-cancellation leak doc): five tests in `tests/test_cancellation.py` were running against the default `:1616` registry, so any leaked `subint-forkserv` descendant from a prior test holds the port and blows up every subsequent run with `TooSlowError` / "address in use". Thread the session-unique `reg_addr` fixture through so each run picks its own port — zombies can no longer poison other tests (they'll only cross-contaminate whatever happens to share their port, which is now nothing). Deats, - add `reg_addr: tuple` fixture param to: - `test_cancel_infinite_streamer` - `test_some_cancels_all` - `test_nested_multierrors` - `test_cancel_via_SIGINT` - `test_cancel_via_SIGINT_other_task` - explicitly pass `registry_addrs=[reg_addr]` to the two `open_nursery()` calls that previously had no kwargs at all (in `test_cancel_via_SIGINT` and `test_cancel_via_SIGINT_other_task`) - add bounded `@pytest.mark.timeout(7, method='thread')` to `test_nested_multierrors` so a hung run doesn't wedge the whole session Still doesn't close the real leak — the `subint_forkserver` backend's `_ForkedProc.kill()` is PID-scoped not tree-scoped, so grandchildren survive teardown regardless of registry port. This commit is just blast-radius containment until that fix lands. See `ai/conc-anal/ subint_forkserver_test_cancellation_leak_issue.md`. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent e3f4f5a commit 1af2121

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tests/test_cancellation.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ async def stream_forever():
275275
timeout=6,
276276
)
277277
async def test_cancel_infinite_streamer(
278-
start_method: str
278+
reg_addr: tuple,
279+
start_method: str,
279280
):
280281
# stream for at most 1 seconds
281282
with (
@@ -341,6 +342,7 @@ async def test_cancel_infinite_streamer(
341342
)
342343
async def test_some_cancels_all(
343344
num_actors_and_errs: tuple,
345+
reg_addr: tuple,
344346
start_method: str,
345347
loglevel: str,
346348
):
@@ -450,8 +452,13 @@ async def spawn_and_error(
450452
await nursery.run_in_actor(*args, **kwargs)
451453

452454

455+
@pytest.mark.timeout(
456+
10,
457+
method='thread',
458+
)
453459
@tractor_test
454460
async def test_nested_multierrors(
461+
reg_addr: tuple,
455462
loglevel: str,
456463
start_method: str,
457464
):
@@ -541,6 +548,7 @@ async def test_nested_multierrors(
541548

542549
@no_windows
543550
def test_cancel_via_SIGINT(
551+
reg_addr: tuple,
544552
loglevel: str,
545553
start_method: str,
546554
):
@@ -553,7 +561,9 @@ def test_cancel_via_SIGINT(
553561

554562
async def main():
555563
with trio.fail_after(2):
556-
async with tractor.open_nursery() as tn:
564+
async with tractor.open_nursery(
565+
registry_addrs=[reg_addr],
566+
) as tn:
557567
await tn.start_actor('sucka')
558568
if 'mp' in start_method:
559569
time.sleep(0.1)
@@ -566,6 +576,7 @@ async def main():
566576

567577
@no_windows
568578
def test_cancel_via_SIGINT_other_task(
579+
reg_addr: tuple,
569580
loglevel: str,
570581
start_method: str,
571582
spawn_backend: str,
@@ -594,7 +605,9 @@ def test_cancel_via_SIGINT_other_task(
594605
async def spawn_and_sleep_forever(
595606
task_status=trio.TASK_STATUS_IGNORED
596607
):
597-
async with tractor.open_nursery() as tn:
608+
async with tractor.open_nursery(
609+
registry_addrs=[reg_addr],
610+
) as tn:
598611
for i in range(3):
599612
await tn.run_in_actor(
600613
sleep_forever,

0 commit comments

Comments
 (0)