Package: remote-pdb
Remote vanilla PDB (over TCP sockets)done right: no extras, proper handling around connection failures and CI. Based
onpdbx.Free software: BSD 2-Clause LicenseInstallationpip install remote-pdbUsageTo open a remote PDB on first available port:fromremote_pdbimportset_traceset_trace()# you'll see the port number in the logsTo use some specific host/port:fromremote_pdbimportRemotePdbRemotePdb('127.0.0.1',4444).set_trace()To connect just runtelnet 127.0.0.1 4444.  When you are finished
debugging, either exit the debugger, or press Control-], then Control-d.Alternately, one can connect with NetCat:nc-C127.0.0.1 4444or Socat:socat readline tcp:127.0.0.1:4444(for line editing and history support).  When finished debugging, either exit
the debugger, or press Control-c.Note that newer Ubuntu disabled readline support in socat, so if you getunknown device/address "readline"try using rlwrap like this:rlwrap socat - tcp:127.0.0.1:4444Using in containersIf you want to connect from the host to remote-pdb running inside the container you should make sure that:The port you will use is mapped (eg:-p4444:4444).The host is set to0.0.0.0(localhost` or ``127.0.0.1will not work because
Docker doesn’t map the port on the local interface).Integration with breakpoint() in Python 3.7+If you are using Python 3.7 one can use the newbreakpoint()built in to invoke
remote PDB. In this case the following environment variable must be set:PYTHONBREAKPOINT=remote_pdb.set_traceThe debugger can then be invoked as follows, without any imports:breakpoint()As thebreakpoint()function does not take any arguments, environment variables can be used to
specify the host and port that the server should listen to. For example, to runscript.pyin such a
way as to maketelnet 127.0.0.1 4444the correct way of connecting, one would run:PYTHONBREAKPOINT=remote_pdb.set_traceREMOTE_PDB_HOST=127.0.0.1REMOTE_PDB_PORT=4444pythonscript.pyIfREMOTE_PDB_HOSTis omitted then a default value of 127.0.0.1 will be used. IfREMOTE_PDB_PORTis
omitted then the first available port will be used. The connection information will be logged to the console,
as with calls toremote_pdb.set_trace().To quiet the output, setREMOTE_PDB_QUIET=1, this will preventRemotePdbfrom producing any output – you’ll probably want to specifyREMOTE_PDB_PORTas well since the randomized port won’t be printed.Note about OS XIn certain scenarios (backgrounded processes) OS X will prevent readline to be imported (and readline is a dependency of pdb).
A workaround (run this early):importsignalsignal.signal(signal.SIGTTOU,signal.SIG_IGN)See#9andcpython#14892.RequirementsPython 2.6, 2.7, 3.2, 3.3 and PyPy are supported.Similar projectsqdbChangelog2.1.0 (2020-07-24)Changed logging to useremote_pdblogger instead of the root one.
Contributed by Terence Honles in#24.2.0.0 (2019-07-31)Fixed inconsistency with normal use ofpdb-BdbQuitwill now be raised on quitting.
Contributed by Anthony Sottile in#18.BACKWARDS INCOMPATIBLE.AddedREMOTE_PDB_QUIET=1to silence output.
Contributed by Anthony Sottile in#19.1.3.0 (2019-03-13)Documented support for Python 3.7’sbreakpoint().Added support for setting the socket listening host/port through theREMOTE_PDB_HOST/REMOTE_PDB_PORTenvironment variables. Contributed by Matthew Wilkes in#14.Removed use ofrwfile wrappers around sockets (turns out socket’smakefileis very buggy in Python 3.6 and
later -output is discarded). Contributed in#13.1.2.0 (2015-09-26)Always print/log listening address.1.1.3 (2015-07-06)Corrected the default frame tracing starts from.1.1.2 (2015-07-06)Small readme update.1.1.1 (2015-07-06)Remove bogusremote_pdbconsole script.1.1.0 (2015-06-21)Fixed buffering issues when running on Python 3 and Windows.1.0.0 (2015-06-15)Added support for PDB++.0.2.1 (2014-03-07)First release on PyPI.