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
subint_forkserver_backend
Gud Boi 2026-05-13 11:59:37 -04:00
parent 10db117864
commit 8aa07a7932
2 changed files with 27 additions and 2 deletions

View File

@ -57,6 +57,7 @@ from tractor.msg._ops import (
limit_plds, limit_plds,
) )
def enc_nsp(obj: Any) -> Any: def enc_nsp(obj: Any) -> Any:
actor: Actor = tractor.current_actor( actor: Actor = tractor.current_actor(
err_on_no_runtime=False, err_on_no_runtime=False,
@ -617,6 +618,17 @@ def test_ext_types_over_ipc(
debug_mode: bool, debug_mode: bool,
pld_spec: Union[Type], pld_spec: Union[Type],
add_hooks: bool, 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 Ensure we can support extension types coverted using
@ -725,18 +737,26 @@ def test_ext_types_over_ipc(
await p.cancel_actor() await p.cancel_actor()
async def fa_main():
with (
trio.fail_after(2),
# ?TODO, investigate? see NOTE above..
# capfd.disabled(),
):
await main()
if ( if (
NamespacePath in pld_types NamespacePath in pld_types
and and
add_hooks add_hooks
): ):
trio.run(main) trio.run(fa_main)
else: else:
with pytest.raises( with pytest.raises(
expected_exception=tractor.RemoteActorError, expected_exception=tractor.RemoteActorError,
) as excinfo: ) as excinfo:
trio.run(main) trio.run(fa_main)
exc = excinfo.value exc = excinfo.value
# bc `.started(nsp: NamespacePath)` will raise # bc `.started(nsp: NamespacePath)` will raise

View File

@ -284,6 +284,11 @@ def test_basic_payload_spec(
return_value: str|None, return_value: str|None,
started_value: int|PldMsg, started_value: int|PldMsg,
pld_check_started_value: bool, 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 Validate the most basic `PldRx` msg-type-spec semantics around