Wrapper around pdb allowing remote debugging via netcat or telnet. This is especially useful in a Tomcat/Jython environment where little debugging tools are available.
Clone or download
Latest commit 7f64e8f Mar 18, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
rpdb Ensure socket closes properly Mar 17, 2016
.gitignore fixed typo Jan 27, 2012
.hgignore Initial commit. May 8, 2010
CHANGES.txt Set release date for 0.1.6 Jan 5, 2016
LICENSE.txt cleanup Jan 27, 2012
MANIFEST.in Initial commit. May 8, 2010
README.rst handle SIGTRAP to set_trace the running frame at any time Dec 3, 2015
setup.py Read the README file with UTF-8 encoding. Nov 21, 2015


rpdb - remote debugger based on pdb

rpdb is a wrapper around pdb that re-routes stdin and stdout to a socket handler. By default it opens the debugger on port 4444:

import rpdb; rpdb.set_trace()

But you can change that by simply instantiating Rpdb manually:

import rpdb
debugger = rpdb.Rpdb(port=12345)

It is known to work on Jython 2.5 to 2.7, Python 2.5 to 3.1. It was written originally for Jython since this is pretty much the only way to debug it when running it on Tomcat.

Upon reaching set_trace(), your script will "hang" and the only way to get it to continue is to access rpdb using telnet, netcat, etc..:

nc 4444

Installation in CPython (standard Python)

pip install rpdb

For a quick, ad hoc alternative, you can copy the entire rpdb subdirectory (the directory directly containing the __init__.py file) to somewhere on your $PYTHONPATH.

Installation in a Tomcat webapp

Just copy the rpdb directory (the one with the __init__.py file) in your WEB-INF/lib/Lib folder along with the standard Jython library (required).

Trigger rpdb with signal

set_trace() can be triggered at any time by using the TRAP signal handler. This allows you to debug a running process independantly of a specific failure or breakpoint:

import rpdb

# As with set_trace, you can optionally specify addr and port
rpdb.handle_trap("", 54321)

Calling handle_trap will overwrite the existing handler for SIGTRAP if one has already been defined in your application.

Known bugs

  • The socket is not always closed properly so you will need to ^C in netcat and Esc+q in telnet to exit after a continue or quit.
  • There is a bug in Jython 2.5/pdb that causes rpdb to stop on ghost breakpoints after you continue ('c'), this is fixed in 2.7b1.


Bertrand Janin <b@janin.com> - http://tamentis.com/

With contributions from (chronological, latest first):

This is inspired by: