From f7ca31c0e463b5f22a2bb87d49f60ede2ca0bd75 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 10 Aug 2025 15:03:15 -0400 Subject: [PATCH] Set `shield` when `.cancel_called` for root crashes Such that we handle them despite a cancellation condition. This is almost always the case, that `root_tn.cancel_scope.cancel_called` is set, by the time the `debug._maybe_enter_pm()` hits. Previous I guess we just weren't actually ever REPL-debugging such cases? Still needs a test obvi. --- tractor/_root.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tractor/_root.py b/tractor/_root.py index 370798dd..4bc9846c 100644 --- a/tractor/_root.py +++ b/tractor/_root.py @@ -478,7 +478,10 @@ async def open_root_actor( # start runtime in a bg sub-task, yield to caller. async with ( - collapse_eg(), + collapse_eg( + bp=True, + hide_tb=False, + ), trio.open_nursery() as root_tn, # XXX, finally-footgun below? @@ -523,6 +526,12 @@ async def open_root_actor( err, api_frame=inspect.currentframe(), debug_filter=debug_filter, + + # XXX NOTE, required to debug root-actor + # crashes under cancellation conditions; so + # most of them! + shield=root_tn.cancel_scope.cancel_called, + # ^TODO? write a (debugger) test for this ya? ) if (