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