From 8aa07a79326e6400208f7e6f8591bfba00e0fb40 Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 13 May 2026 11:59:37 -0400 Subject: [PATCH] Add `set_fork_aware_capture`, timeout to msg tests - `test_ext_types_over_ipc`: wrap `main()` in `fa_main()` with `trio.fail_after(2)` + commented `capfd.disabled()` investigation (pytest#14444). - `test_basic_payload_spec`: add fixture param with note on fork-spawner hang prevention. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tests/msg/test_ext_types_msgspec.py | 24 ++++++++++++++++++++++-- tests/msg/test_pldrx_limiting.py | 5 +++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/msg/test_ext_types_msgspec.py b/tests/msg/test_ext_types_msgspec.py index b334b64f..f07d375c 100644 --- a/tests/msg/test_ext_types_msgspec.py +++ b/tests/msg/test_ext_types_msgspec.py @@ -57,6 +57,7 @@ from tractor.msg._ops import ( limit_plds, ) + def enc_nsp(obj: Any) -> Any: actor: Actor = tractor.current_actor( err_on_no_runtime=False, @@ -617,6 +618,17 @@ def test_ext_types_over_ipc( debug_mode: bool, pld_spec: Union[Type], add_hooks: bool, + + set_fork_aware_capture, + # ^^XXX? for forking spawners + + # capfd: pytest.CaptureFixture, + # ^^NOTE, super interesting that if + # we disable this below then the tpt-layer + # suffers as an "unclean EOF"?? + # ?TODO, determine why/how that mks sense when addressing, + # https://github.com/pytest-dev/pytest/issues/14444 + # ): ''' Ensure we can support extension types coverted using @@ -725,18 +737,26 @@ def test_ext_types_over_ipc( await p.cancel_actor() + async def fa_main(): + with ( + trio.fail_after(2), + # ?TODO, investigate? see NOTE above.. + # capfd.disabled(), + ): + await main() + if ( NamespacePath in pld_types and add_hooks ): - trio.run(main) + trio.run(fa_main) else: with pytest.raises( expected_exception=tractor.RemoteActorError, ) as excinfo: - trio.run(main) + trio.run(fa_main) exc = excinfo.value # bc `.started(nsp: NamespacePath)` will raise diff --git a/tests/msg/test_pldrx_limiting.py b/tests/msg/test_pldrx_limiting.py index 1a8b6117..24173920 100644 --- a/tests/msg/test_pldrx_limiting.py +++ b/tests/msg/test_pldrx_limiting.py @@ -284,6 +284,11 @@ def test_basic_payload_spec( return_value: str|None, started_value: int|PldMsg, pld_check_started_value: bool, + + set_fork_aware_capture, + # ^XXX TODO? for forking spawners, seems to prevent hangs when + # --capture=sys not set, but only for a while then the problem + # accumulates? ): ''' Validate the most basic `PldRx` msg-type-spec semantics around