First try: switch debug machinery over to `pdbp` B)

master^2
Tyler Goodlet 2023-04-15 19:49:25 -04:00
parent 23cffbd940
commit cc82447db6
1 changed files with 22 additions and 20 deletions

View File

@ -37,6 +37,7 @@ from typing import (
) )
from types import FrameType from types import FrameType
import pdbp
import tractor import tractor
import trio import trio
from trio_typing import TaskStatus from trio_typing import TaskStatus
@ -54,15 +55,16 @@ from ._exceptions import (
from ._ipc import Channel from ._ipc import Channel
try: # TODO: we can drop this now yah?
# wtf: only exported when installed in dev mode? # try:
import pdbpp # # wtf: only exported when installed in dev mode?
except ImportError: # import pdbp
# pdbpp is installed in regular mode...it monkey patches stuff # except ImportError:
import pdb # # pdbpp is installed in regular mode...it monkey patches stuff
xpm = getattr(pdb, 'xpm', None) # import pdb
assert xpm, "pdbpp is not installed?" # type: ignore # xpm = getattr(pdb, 'xpm', None)
pdbpp = pdb # assert xpm, "pdbpp is not installed?" # type: ignore
# pdbpp = pdb
log = get_logger(__name__) log = get_logger(__name__)
@ -154,22 +156,22 @@ class Lock:
cls.repl = None cls.repl = None
class TractorConfig(pdbpp.DefaultConfig): class TractorConfig(pdbp.DefaultConfig):
''' '''
Custom ``pdbpp`` goodness. Custom ``pdbp`` goodness.
''' '''
# use_pygments = True # use_pygments = True
# sticky_by_default = True sticky_by_default = True
enable_hidden_frames = False enable_hidden_frames = False
class MultiActorPdb(pdbpp.Pdb): class MultiActorPdb(pdbp.Pdb):
''' '''
Add teardown hooks to the regular ``pdbpp.Pdb``. Add teardown hooks to the regular ``pdbp.Pdb``.
''' '''
# override the pdbpp config with our coolio one # override the pdbp config with our coolio one
DefaultConfig = TractorConfig DefaultConfig = TractorConfig
# def preloop(self): # def preloop(self):
@ -313,7 +315,7 @@ async def lock_tty_for_child(
) -> str: ) -> str:
''' '''
Lock the TTY in the root process of an actor tree in a new Lock the TTY in the root process of an actor tree in a new
inter-actor-context-task such that the ``pdbpp`` debugger console inter-actor-context-task such that the ``pdbp`` debugger console
can be mutex-allocated to the calling sub-actor for REPL control can be mutex-allocated to the calling sub-actor for REPL control
without interference by other processes / threads. without interference by other processes / threads.
@ -433,7 +435,7 @@ async def wait_for_parent_stdin_hijack(
def mk_mpdb() -> tuple[MultiActorPdb, Callable]: def mk_mpdb() -> tuple[MultiActorPdb, Callable]:
pdb = MultiActorPdb() pdb = MultiActorPdb()
# signal.signal = pdbpp.hideframe(signal.signal) # signal.signal = pdbp.hideframe(signal.signal)
Lock.shield_sigint() Lock.shield_sigint()
@ -583,7 +585,7 @@ async def _breakpoint(
# # frame = sys._getframe() # # frame = sys._getframe()
# # last_f = frame.f_back # # last_f = frame.f_back
# # last_f.f_globals['__tracebackhide__'] = True # # last_f.f_globals['__tracebackhide__'] = True
# # signal.signal = pdbpp.hideframe(signal.signal) # # signal.signal = pdbp.hideframe(signal.signal)
def shield_sigint_handler( def shield_sigint_handler(
@ -743,7 +745,7 @@ def shield_sigint_handler(
# https://github.com/goodboy/tractor/issues/130#issuecomment-663752040 # https://github.com/goodboy/tractor/issues/130#issuecomment-663752040
# https://github.com/prompt-toolkit/python-prompt-toolkit/blob/c2c6af8a0308f9e5d7c0e28cb8a02963fe0ce07a/prompt_toolkit/patch_stdout.py # https://github.com/prompt-toolkit/python-prompt-toolkit/blob/c2c6af8a0308f9e5d7c0e28cb8a02963fe0ce07a/prompt_toolkit/patch_stdout.py
# XXX: lol, see ``pdbpp`` issue: # XXX LEGACY: lol, see ``pdbpp`` issue:
# https://github.com/pdbpp/pdbpp/issues/496 # https://github.com/pdbpp/pdbpp/issues/496
@ -798,7 +800,7 @@ def _post_mortem(
# https://github.com/pdbpp/pdbpp/issues/480 # https://github.com/pdbpp/pdbpp/issues/480
# TODO: help with a 3.10+ major release if/when it arrives. # TODO: help with a 3.10+ major release if/when it arrives.
pdbpp.xpm(Pdb=lambda: pdb) pdbp.xpm(Pdb=lambda: pdb)
post_mortem = partial( post_mortem = partial(