diff --git a/tractor/_debug.py b/tractor/_debug.py index 16072d5..592813c 100644 --- a/tractor/_debug.py +++ b/tractor/_debug.py @@ -2,6 +2,7 @@ Multi-core debugging for da peeps! """ +from __future__ import annotations import bdb import sys from functools import partial @@ -20,12 +21,14 @@ from ._exceptions import is_multi_cancelled try: # wtf: only exported when installed in dev mode? import pdbpp + except ImportError: # pdbpp is installed in regular mode...it monkey patches stuff import pdb assert pdb.xpm, "pdbpp is not installed?" # type: ignore pdbpp = pdb + log = get_logger(__name__) @@ -85,6 +88,23 @@ class PdbwTeardown(pdbpp.Pdb): _pdb_release_hook() +def _mk_pdb() -> PdbwTeardown: + + # XXX: setting these flags on the pdb instance are absolutely + # critical to having ctrl-c work in the ``trio`` standard way! The + # stdlib's pdb supports entering the current sync frame on a SIGINT, + # with ``trio`` we pretty much never want this and if we did we can + # handle it in the ``tractor`` task runtime. + # global pdb + + pdb = PdbwTeardown() + pdb.nosigint = True + pdb.allow_kbdint = True + opts = (allow_kbdint, nosigint) = pdb.allow_kbdint, pdb.nosigint + print(f'`pdbp` was configured with {opts}') + return pdb + + # TODO: will be needed whenever we get to true remote debugging. # XXX see https://github.com/goodboy/tractor/issues/130 @@ -443,21 +463,6 @@ async def _breakpoint( debug_func(actor) -def _mk_pdb() -> PdbwTeardown: - - # XXX: setting these flags on the pdb instance are absolutely - # critical to having ctrl-c work in the ``trio`` standard way! The - # stdlib's pdb supports entering the current sync frame on a SIGINT, - # with ``trio`` we pretty much never want this and if we did we can - # handle it in the ``tractor`` task runtime. - - pdb = PdbwTeardown() - pdb.allow_kbdint = True - pdb.nosigint = True - - return pdb - - def _set_trace(actor=None): pdb = _mk_pdb() diff --git a/tractor/_supervise.py b/tractor/_supervise.py index a82186e..0a400ea 100644 --- a/tractor/_supervise.py +++ b/tractor/_supervise.py @@ -307,8 +307,8 @@ async def _open_and_supervise_one_cancels_all_nursery( f'child {_debug._global_actor_in_debug}\n' 'Waiting on tty lock to release..') - # with trio.CancelScope(shield=True): - await debug_complete.wait() + with trio.CancelScope(shield=True): + await debug_complete.wait() # if the caller's scope errored then we activate our # one-cancels-all supervisor strategy (don't