From a86774c40fc27d7fdee59b1eab7ab3d4f58f9300 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 25 Feb 2025 19:37:30 -0500 Subject: [PATCH] Flip to `strict_exception_groups=False` in core tns Since it'll likely need a bit of detailing to get the test suite running identically with strict egs (exception groups), i've opted to just flip the switch on a few core nursery scopes for now until as such a time i can focus enough to port the matching internals.. Xp --- tractor/_context.py | 5 ++++- tractor/_root.py | 17 +++++++++++++---- tractor/_rpc.py | 8 ++++++-- tractor/_supervise.py | 10 ++++++++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/tractor/_context.py b/tractor/_context.py index 4a20c2b..8c65b5a 100644 --- a/tractor/_context.py +++ b/tractor/_context.py @@ -1982,7 +1982,10 @@ async def open_context_from_portal( ctxc_from_callee: ContextCancelled|None = None try: async with ( - trio.open_nursery() as tn, + trio.open_nursery( + strict_exception_groups=False, + ) as tn, + msgops.maybe_limit_plds( ctx=ctx, spec=ctx_meta.get('pld_spec'), diff --git a/tractor/_root.py b/tractor/_root.py index e10b02e..ed71f69 100644 --- a/tractor/_root.py +++ b/tractor/_root.py @@ -362,7 +362,10 @@ async def open_root_actor( ) # start the actor runtime in a new task - async with trio.open_nursery() as nursery: + async with trio.open_nursery( + strict_exception_groups=False, + # ^XXX^ TODO? instead unpack any RAE as per "loose" style? + ) as nursery: # ``_runtime.async_main()`` creates an internal nursery # and blocks here until any underlying actor(-process) @@ -457,12 +460,19 @@ def run_daemon( start_method: str | None = None, debug_mode: bool = False, + + # TODO, support `infected_aio=True` mode by, + # - calling the appropriate entrypoint-func from `.to_asyncio` + # - maybe init-ing `greenback` as done above in + # `open_root_actor()`. + **kwargs ) -> None: ''' - Spawn daemon actor which will respond to RPC; the main task simply - starts the runtime and then sleeps forever. + Spawn a root (daemon) actor which will respond to RPC; the main + task simply starts the runtime and then blocks via embedded + `trio.sleep_forever()`. This is a very minimal convenience wrapper around starting a "run-until-cancelled" root actor which can be started with a set @@ -475,7 +485,6 @@ def run_daemon( importlib.import_module(path) async def _main(): - async with open_root_actor( registry_addrs=registry_addrs, name=name, diff --git a/tractor/_rpc.py b/tractor/_rpc.py index 1849cf6..1f34c23 100644 --- a/tractor/_rpc.py +++ b/tractor/_rpc.py @@ -621,7 +621,11 @@ async def _invoke( tn: trio.Nursery rpc_ctx_cs: CancelScope async with ( - trio.open_nursery() as tn, + trio.open_nursery( + strict_exception_groups=False, + # ^XXX^ TODO? instead unpack any RAE as per "loose" style? + + ) as tn, msgops.maybe_limit_plds( ctx=ctx, spec=ctx_meta.get('pld_spec'), @@ -734,8 +738,8 @@ async def _invoke( # XXX: do we ever trigger this block any more? except ( BaseExceptionGroup, - trio.Cancelled, BaseException, + trio.Cancelled, ) as scope_error: if ( diff --git a/tractor/_supervise.py b/tractor/_supervise.py index de26807..b07498b 100644 --- a/tractor/_supervise.py +++ b/tractor/_supervise.py @@ -395,7 +395,10 @@ async def _open_and_supervise_one_cancels_all_nursery( # `ActorNursery.start_actor()`). # errors from this daemon actor nursery bubble up to caller - async with trio.open_nursery() as da_nursery: + async with trio.open_nursery( + strict_exception_groups=False, + # ^XXX^ TODO? instead unpack any RAE as per "loose" style? + ) as da_nursery: try: # This is the inner level "run in actor" nursery. It is # awaited first since actors spawned in this way (using @@ -405,7 +408,10 @@ async def _open_and_supervise_one_cancels_all_nursery( # immediately raised for handling by a supervisor strategy. # As such if the strategy propagates any error(s) upwards # the above "daemon actor" nursery will be notified. - async with trio.open_nursery() as ria_nursery: + async with trio.open_nursery( + strict_exception_groups=False, + # ^XXX^ TODO? instead unpack any RAE as per "loose" style? + ) as ria_nursery: an = ActorNursery( actor,