From c63b94f61f25e11569c5031eca7efa340f91f159 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 28 Dec 2024 14:35:05 -0500 Subject: [PATCH] Expose `debug_filter` from `open_root_actor()` also Such that actor-runtime graceful cancel handling can be used throughout any process tree. --- tractor/_root.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tractor/_root.py b/tractor/_root.py index 38ddbe2..e10b02e 100644 --- a/tractor/_root.py +++ b/tractor/_root.py @@ -95,6 +95,13 @@ async def open_root_actor( hide_tb: bool = True, + # XXX, proxied directly to `.devx._debug._maybe_enter_pm()` + # for REPL-entry logic. + debug_filter: Callable[ + [BaseException|BaseExceptionGroup], + bool, + ] = lambda err: not is_multi_cancelled(err), + # TODO, a way for actors to augment passing derived # read-only state to sublayers? # extra_rt_vars: dict|None = None, @@ -379,6 +386,7 @@ async def open_root_actor( Exception, BaseExceptionGroup, ) as err: + # XXX NOTE XXX see equiv note inside # `._runtime.Actor._stream_handler()` where in the # non-root or root-that-opened-this-mahually case we @@ -387,11 +395,15 @@ async def open_root_actor( entered: bool = await _debug._maybe_enter_pm( err, api_frame=inspect.currentframe(), + debug_filter=debug_filter, ) + if ( not entered and - not is_multi_cancelled(err) + not is_multi_cancelled( + err, + ) ): logger.exception('Root actor crashed\n')