From d6ddc47e5875faac20ce1d5a748fbcabecddfaf1 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 5 Sep 2021 15:21:20 -0400 Subject: [PATCH] Test non-shielding root lock acquire on breakpoint entry --- tractor/_debug.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tractor/_debug.py b/tractor/_debug.py index 6e1d7f0..16072d5 100644 --- a/tractor/_debug.py +++ b/tractor/_debug.py @@ -254,6 +254,7 @@ async def _hijack_stdin_for_child( # assert await stream.receive() == 'pdb_unlock' except ( + trio.MultiError, trio.BrokenResourceError, trio.Cancelled, # by local cancellation trio.ClosedResourceError, # by self._rx_chan @@ -343,6 +344,7 @@ async def _breakpoint( except tractor.ContextCancelled: log.warning('Root actor cancelled debug lock') + raise finally: log.debug(f"Exiting debugger for actor {actor}") @@ -407,10 +409,14 @@ async def _breakpoint( 'Root actor attempting to shield-acquire active tty lock' f' owned by {_global_actor_in_debug}') - with trio.CancelScope(shield=True): - # must shield here to avoid hitting a ``Cancelled`` and - # a child getting stuck bc we clobbered the tty - await _debug_lock.acquire() + stats = _debug_lock.statistics() + if stats.owner: + breakpoint() + + # with trio.CancelScope(shield=True): + # must shield here to avoid hitting a ``Cancelled`` and + # a child getting stuck bc we clobbered the tty + await _debug_lock.acquire() else: # may be cancelled