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.
POST_final_eg_refinements_failafter_investigation
Tyler Goodlet 2025-08-10 15:03:15 -04:00
parent e50ba3e8a6
commit f7ca31c0e4
1 changed files with 10 additions and 1 deletions

View File

@ -478,7 +478,10 @@ async def open_root_actor(
# start runtime in a bg sub-task, yield to caller. # start runtime in a bg sub-task, yield to caller.
async with ( async with (
collapse_eg(), collapse_eg(
bp=True,
hide_tb=False,
),
trio.open_nursery() as root_tn, trio.open_nursery() as root_tn,
# XXX, finally-footgun below? # XXX, finally-footgun below?
@ -523,6 +526,12 @@ async def open_root_actor(
err, err,
api_frame=inspect.currentframe(), api_frame=inspect.currentframe(),
debug_filter=debug_filter, 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 ( if (