From 61d2307e5294b3aea5ff59d039c2bfe70ac64224 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 31 Aug 2021 17:46:00 -0400 Subject: [PATCH] Unlock pdb tty on all possible net faults --- tractor/_debug.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tractor/_debug.py b/tractor/_debug.py index e9bfaf1..6e1d7f0 100644 --- a/tractor/_debug.py +++ b/tractor/_debug.py @@ -253,7 +253,11 @@ async def _hijack_stdin_for_child( # try: # assert await stream.receive() == 'pdb_unlock' - except trio.BrokenResourceError: + except ( + trio.BrokenResourceError, + trio.Cancelled, # by local cancellation + trio.ClosedResourceError, # by self._rx_chan + ) as err: # XXX: there may be a race with the portal teardown # with the calling actor which we can safely ignore. # The alternative would be sending an ack message @@ -262,6 +266,9 @@ async def _hijack_stdin_for_child( if lock and lock.locked(): lock.release() + if isinstance(err, trio.Cancelled): + raise + log.debug(f"TTY lock released, remote task: {task_name}:{subactor_uid}") return "pdb_unlock_complete"