Open goodboy opened 4 years ago
Relevant links from ptk
:
tmux
-like app: prompt-toolkit/python-prompt-toolkit#1087ptpython
, ptpdb
which is likely where we'll need to startFollow up from prompt-toolkit/python-prompt-toolkit#1204:
ptpdb
to ptk 3.0 and it's looking a bit rough.ipython
core to make ipdb
work with (as mentioned) new ptk 3.0 features
As part of the journey in #129 I discovered that no-one seems to have solved the problem of getting the fancy features of a modern Python debugger working in remote debugging applications. Though I haven't tested them all, the list in #113 seems to mostly contain systems which rely on telnet servers (or other network IPC magic) but none of them actually solve the issue of how to get the features in the local client that would normally only be possible when the remote process is connected to a tty.
The problem
Standard fancy (read human enhanced) debugger repls (including the stdlib's
pdb
which usesrlcompleter
, andpdb++
) rely on libraries such as GNU readline to get things like completion and CLI "editting controls". There seems to be no way to get these features with readline based systems in a remote debugging context since Python's use ofreadline
requires that the process is launched under a tty/pty system. Ideally these features are available in such use cases to make debugging of remote systems sane and efficient for the user.Evidence
In #129 I was able to verify that launching subprocesses with stdin as a unix pipe indeed causes no readline systems to be loaded. I haven't been able to find a remote debugger that supports this feature either (but of course hopefully someone will prove me wrong!).
Possible solutions
in the near term: we can not spawn with
stdin
as a pipe and instead let child processes stay connected to the parent tty (this is actually whattrip
does and it works):consider a debugger that doesn't use the stdlib's
readline
python-prompt-toolkit
which is specifically a replacement forreadline
ptk
can work without being connected to a tty/pty.ipdb
(sinceipython
usesptk
underneath) ifptk
was configured properly (it currently doesn't work any better then thereadline
options based on my testing in https://github.com/goodboy/tractor/tree/stin_char_relay).work with debugger's that want to move to
ptk
to get this functionality supported in their initial integration such as withpdbpp
in pdbpp/pdbpp#362Other notes
pytprocess
does get these features in subprocs as we'd expect but ideally we aren't spending time wrapping this withtrio
since it still won't work for the network remote debugging cases.stdin_relay_chars
branch.ptyprocess
from above).stty
for checking local tty settingsrlcompleter
notes thereadline
limitation for any doubters.epdb
's server mode (which seems to have the best integration withpdbpp
) has no notion of supporting this afaict.trio
on how to hook up subprocs for receiving input.Remote debugging possible hacks or solutions
python-remote-pdb
offers areadline
hack usingnc
orsocat
which may be usable in the near termptyprocess
has done fromtractor
spawning machinery and keeping compat with the publictrio
apiIdeally
ptk
to support all it's features without requiring a tty whatsoever and then being able to simply talk to atractor
actor running it.