python-rpdb
Fork me on GitHub

If you are looking for a way to debug Python application in a terminal-hostile environment, you've come to the right place. rpdb is a wrapper around pdb using a tcp socket to communicate with the outside world.

pdb hostile environments

Typically you won't be able to have a console/terminal (hence no debugger) when writing Python application for:

  • CGI scripts
  • Tomcat + Jython
  • any device with TCP/IP but no TTY

how it works

This is essentially a wrapper around pdb that will re-route stdin and stdout to a socket handler. By default it opens the debugger on port 4444.

[...]
import rpdb; rpdb.set_trace()
[...]

You can also change the port by instantiating Rpdb manually:

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

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

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

$ nc 127.0.0.1 4444

download / installation

You can download it from the cheese shop: http://pypi.python.org/pypi/rpdb/ or with pip:

$ pip rpdb

If you are creating a Webapp with Tomcat and Jython, you will need the Jython library installed in WEB-INF/lib/Lib and you can put rpdb there too.

references

suggestions, patches welcome

Feel free to clone my repository and send patches, forks or whatever:

https://github.com/tamentis/rpdb

Bertrand Janin <b@janin.com> · Powered by Python, OpenBSD, a teashpoon of WTF & the spirit of the UNIX gods.