Try ipdb to get tab-complete without a tty

It doesn't work but in theory since ipython uses python-prompt-toolkit
this may be possible (and is really the best solution over trying to
hack ttys/ptys in the child). If `ipdb` is installed try using it.
stin_char_relay
Tyler Goodlet 2020-07-24 15:15:52 -04:00
parent 042f2326db
commit 7886a9fa64
1 changed files with 13 additions and 6 deletions

View File

@ -97,6 +97,12 @@ def _breakpoint(debug_func) -> Awaitable[None]:
in subactors.
"""
actor = tractor.current_actor()
try:
import ipdb
db = ipdb
except ImportError:
import pdb
db = pdb
async def wait_for_parent_stdin_hijack():
log.debug('Breakpoint engaged!')
@ -116,14 +122,14 @@ def _breakpoint(debug_func) -> Awaitable[None]:
# block here one frame up where ``breakpoint()``
# was awaited and begin handling stdin
debug_func(actor)
debug_func(actor, db)
# this must be awaited by caller
return wait_for_parent_stdin_hijack()
def _set_trace(actor):
pdb.set_trace(
def _set_trace(actor, dbmod):
dbmod.set_trace(
header=f"\nAttaching pdb to actor: {actor.uid}\n",
# start 2 levels up
frame=sys._getframe().f_back.f_back,
@ -136,9 +142,10 @@ breakpoint = partial(
)
def _post_mortem(actor):
log.error(f"\nAttaching to pdb in crashed actor: {actor.uid}\n")
pdb.post_mortem()
def _post_mortem(actor, dbmod):
log.error(
f"\nAttaching to {dbmod} in crashed actor: {actor.uid}\n")
dbmod.post_mortem()
post_mortem = partial(