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?

TODO, still needs a test obvi!
main^2
Tyler Goodlet 2025-08-10 15:03:15 -04:00
parent d1599449e7
commit 28a6354e81
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.
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 (