diff --git a/examples/advanced_faults/ipc_failure_during_stream.py b/examples/advanced_faults/ipc_failure_during_stream.py index 60b28c3..950d5a6 100644 --- a/examples/advanced_faults/ipc_failure_during_stream.py +++ b/examples/advanced_faults/ipc_failure_during_stream.py @@ -62,7 +62,9 @@ async def recv_and_spawn_net_killers( await ctx.started() async with ( ctx.open_stream() as stream, - trio.open_nursery() as n, + trio.open_nursery( + strict_exception_groups=False, + ) as tn, ): async for i in stream: print(f'child echoing {i}') @@ -77,11 +79,11 @@ async def recv_and_spawn_net_killers( i >= break_ipc_after ): broke_ipc = True - n.start_soon( + tn.start_soon( iter_ipc_stream, stream, ) - n.start_soon( + tn.start_soon( partial( break_ipc_then_error, stream=stream, diff --git a/examples/debugging/multi_daemon_subactors.py b/examples/debugging/multi_daemon_subactors.py index 7844cce..844a228 100644 --- a/examples/debugging/multi_daemon_subactors.py +++ b/examples/debugging/multi_daemon_subactors.py @@ -21,11 +21,13 @@ async def name_error(): async def main(): - """Test breakpoint in a streaming actor. - """ + ''' + Test breakpoint in a streaming actor. + + ''' async with tractor.open_nursery( debug_mode=True, - # loglevel='cancel', + loglevel='cancel', # loglevel='devx', ) as n: diff --git a/examples/debugging/multi_subactor_root_errors.py b/examples/debugging/multi_subactor_root_errors.py index 640f222..31bb7dd 100644 --- a/examples/debugging/multi_subactor_root_errors.py +++ b/examples/debugging/multi_subactor_root_errors.py @@ -40,7 +40,7 @@ async def main(): """ async with tractor.open_nursery( debug_mode=True, - # loglevel='cancel', + loglevel='devx', ) as n: # spawn both actors diff --git a/examples/full_fledged_streaming_service.py b/examples/full_fledged_streaming_service.py index be4c372..d859f64 100644 --- a/examples/full_fledged_streaming_service.py +++ b/examples/full_fledged_streaming_service.py @@ -91,7 +91,7 @@ async def main() -> list[int]: an: ActorNursery async with tractor.open_nursery( loglevel='cancel', - debug_mode=True, + # debug_mode=True, ) as an: seed = int(1e3) diff --git a/tests/devx/test_debugger.py b/tests/devx/test_debugger.py index 8b723c6..171e983 100644 --- a/tests/devx/test_debugger.py +++ b/tests/devx/test_debugger.py @@ -309,10 +309,13 @@ def test_subactor_breakpoint( child.expect(EOF) assert in_prompt_msg( - child, - ['RemoteActorError:', + child, [ + 'MessagingError:', + 'RemoteActorError:', "('breakpoint_forever'", - 'bdb.BdbQuit',] + 'bdb.BdbQuit', + ], + pause_on_false=True, ) diff --git a/tests/test_advanced_faults.py b/tests/test_advanced_faults.py index a4d1779..85bac93 100644 --- a/tests/test_advanced_faults.py +++ b/tests/test_advanced_faults.py @@ -3,7 +3,6 @@ Sketchy network blackoutz, ugly byzantine gens, puedes eschuchar la cancelacion?.. ''' -import itertools from functools import partial from types import ModuleType @@ -230,13 +229,10 @@ def test_ipc_channel_break_during_stream( # get raw instance from pytest wrapper value = excinfo.value if isinstance(value, ExceptionGroup): - value = next( - itertools.dropwhile( - lambda exc: not isinstance(exc, expect_final_exc), - value.exceptions, - ) - ) - assert value + excs = value.exceptions + assert len(excs) == 1 + final_exc = excs[0] + assert isinstance(final_exc, expect_final_exc) @tractor.context diff --git a/tests/test_advanced_streaming.py b/tests/test_advanced_streaming.py index 3134b9c..64f2416 100644 --- a/tests/test_advanced_streaming.py +++ b/tests/test_advanced_streaming.py @@ -307,7 +307,15 @@ async def inf_streamer( async with ( ctx.open_stream() as stream, - trio.open_nursery() as tn, + + # XXX TODO, INTERESTING CASE!! + # - if we don't collapse the eg then the embedded + # `trio.EndOfChannel` doesn't propagate directly to the above + # .open_stream() parent, resulting in it also raising instead + # of gracefully absorbing as normal.. so how to handle? + trio.open_nursery( + strict_exception_groups=False, + ) as tn, ): async def close_stream_on_sentinel(): async for msg in stream: diff --git a/tests/test_cancellation.py b/tests/test_cancellation.py index 6da9d63..2d43ee2 100644 --- a/tests/test_cancellation.py +++ b/tests/test_cancellation.py @@ -519,7 +519,9 @@ def test_cancel_via_SIGINT_other_task( async def main(): # should never timeout since SIGINT should cancel the current program with trio.fail_after(timeout): - async with trio.open_nursery() as n: + async with trio.open_nursery( + strict_exception_groups=False, + ) as n: await n.start(spawn_and_sleep_forever) if 'mp' in spawn_backend: time.sleep(0.1) @@ -612,6 +614,12 @@ def test_fast_graceful_cancel_when_spawn_task_in_soft_proc_wait_for_daemon( nurse.start_soon(delayed_kbi) await p.run(do_nuthin) + + # need to explicitly re-raise the lone kbi..now + except* KeyboardInterrupt as kbi_eg: + assert (len(excs := kbi_eg.exceptions) == 1) + raise excs[0] + finally: duration = time.time() - start if duration > timeout: diff --git a/tests/test_caps_based_msging.py b/tests/test_caps_based_msging.py index 6064c2c..ba2bb10 100644 --- a/tests/test_caps_based_msging.py +++ b/tests/test_caps_based_msging.py @@ -874,13 +874,13 @@ def chk_pld_type( return roundtrip -def test_limit_msgspec(): - +def test_limit_msgspec( + debug_mode: bool, +): async def main(): async with tractor.open_root_actor( - debug_mode=True + debug_mode=debug_mode, ): - # ensure we can round-trip a boxing `PayloadMsg` assert chk_pld_type( payload_spec=Any, diff --git a/tests/test_child_manages_service_nursery.py b/tests/test_child_manages_service_nursery.py index 956fccd..540e9b2 100644 --- a/tests/test_child_manages_service_nursery.py +++ b/tests/test_child_manages_service_nursery.py @@ -95,8 +95,8 @@ async def trio_main( # stash a "service nursery" as "actor local" (aka a Python global) global _nursery - n = _nursery - assert n + tn = _nursery + assert tn async def consume_stream(): async with wrapper_mngr() as stream: @@ -104,10 +104,10 @@ async def trio_main( print(msg) # run 2 tasks to ensure broadcaster chan use - n.start_soon(consume_stream) - n.start_soon(consume_stream) + tn.start_soon(consume_stream) + tn.start_soon(consume_stream) - n.start_soon(trio_sleep_and_err) + tn.start_soon(trio_sleep_and_err) await trio.sleep_forever() @@ -119,8 +119,8 @@ async def open_actor_local_nursery( global _nursery async with trio.open_nursery( strict_exception_groups=False, - ) as n: - _nursery = n + ) as tn: + _nursery = tn await ctx.started() await trio.sleep(10) # await trio.sleep(1) @@ -134,7 +134,7 @@ async def open_actor_local_nursery( # never yields back.. aka a scenario where the # ``tractor.context`` task IS NOT in the service n's cancel # scope. - n.cancel_scope.cancel() + tn.cancel_scope.cancel() @pytest.mark.parametrize( @@ -159,7 +159,7 @@ def test_actor_managed_trio_nursery_task_error_cancels_aio( async with tractor.open_nursery() as n: p = await n.start_actor( 'nursery_mngr', - infect_asyncio=asyncio_mode, + infect_asyncio=asyncio_mode, # TODO, is this enabling debug mode? enable_modules=[__name__], ) async with ( diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 508fdbe..8d014ce 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -181,7 +181,9 @@ async def spawn_and_check_registry( try: async with tractor.open_nursery() as n: - async with trio.open_nursery() as trion: + async with trio.open_nursery( + strict_exception_groups=False, + ) as trion: portals = {} for i in range(3): diff --git a/tests/test_trioisms.py b/tests/test_trioisms.py index fad99f1..449ddcc 100644 --- a/tests/test_trioisms.py +++ b/tests/test_trioisms.py @@ -101,6 +101,7 @@ def test_stashed_child_nursery(use_start_soon): def test_acm_embedded_nursery_propagates_enter_err( canc_from_finally: bool, unmask_from_canc: bool, + debug_mode: bool, ): ''' Demo how a masking `trio.Cancelled` could be handled by unmasking from the @@ -174,7 +175,9 @@ def test_acm_embedded_nursery_propagates_enter_err( await trio.lowlevel.checkpoint() async def _main(): - with tractor.devx.open_crash_handler() as bxerr: + with tractor.devx.maybe_open_crash_handler( + pdb=debug_mode, + ) as bxerr: assert not bxerr.value async with (