Skip to main content

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)
debugger.set_trace()

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 127.0.0.1 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
rpdb.handle_trap()

# As with set_trace, you can optionally specify addr and port
rpdb.handle_trap("0.0.0.0", 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.

Author(s)

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

With contributions from (chronological, latest first):

This is inspired by:

0.1.6 (2015-01-05)

  • Give access to attributes of stdin and stdout (by @fuxpavel).

  • Add rpdb.post_mortem(), similar to pdb.post_mortem() (by @CamDavidsonPilon).

0.1.5 (2014-10-16)

  • Write addr/port to stderr instead of stdout (thanks to @onlynone).

  • Allow for dynamic host port (thanks to @onlynone).

  • Make q/quit do proper cleanup (@kenmanheimer)

  • Benignly disregard repeated rpdb.set_trace() to same port as currently active session (@kenmanheimer)

  • Extend backwards compatibility down to Python 2.5 (@kenmanheimer)

0.1.4 (2014-04-28)

  • Expose the addr, port arguments to the set_trace method (thanks to @niedbalski).

0.1.3 (2013-08-02)

  • Remove a try/finally that seemed to shift the trace location (thanks to k4ml@github).

0.1.2 (2012-01-26)

  • Catch IOError raised by print in initialization, it may not work in some environments (e.g. mod_wsgi). (Menno Smits)

0.1.1 (2010-05-09)

Initial release.

Metadata

Release files for rpdb 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rpdb 0.1.6
File Size Uploaded
rpdb-0.1.6.tar.gz 4.3 kB Details

Release files / rpdb-0.1.6.tar.gz

Download URL rpdb-0.1.6.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5d1a1cee34378ab075879dc30fa6328d448a9f680a66c4e84cac7382ad92f15f
BLAKE2b-256 checksum
How to use checksums
53b76663ec9c0157cf7c766bd4c9dca957ca744f0b3b16c945be7e8f8d0b2142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.6 This release

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page