Skip to main content

pdb wrapper with remote access via tcp socket

Project description

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 independently 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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rpdb-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

rpdb-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file rpdb-0.2.0.tar.gz.

File metadata

  • Download URL: rpdb-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.13.1 Darwin/24.1.0

File hashes

Hashes for rpdb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8346f0dd498a1c30768af3d3528cdfe8086d8c057c9fccb5430b5aec32ae16ab
MD5 4200ec41693da5990c15ab21b235bc42
BLAKE2b-256 0f872dc67e3d5a005173b2e4165bdfdeb302ef38393b16312afe70f7a252f3ae

See more details on using hashes here.

File details

Details for the file rpdb-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rpdb-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.13.1 Darwin/24.1.0

File hashes

Hashes for rpdb-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20e59ed87bbc0ec6a89ea883d8620f26c6e0877b851a49e19c239ad2c6bd4f49
MD5 aeec73c3f53ee112ac8e9fcd98c15fd5
BLAKE2b-256 56dd39ee98f8fc0163f4df6264525fff2b87eef4b3d1a48db5936261e029ba15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page