diff --git a/tractor/_debug.py b/tractor/_debug.py index 7aac4eb..8b066e4 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 @@ -27,12 +28,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__) @@ -92,6 +95,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 @@ -461,21 +481,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()