Remote PDB

2.1.0 · active · verified Sun Apr 12

Remote-pdb provides a robust, vanilla PDB (Python Debugger) interface over TCP sockets, designed for remote debugging scenarios. It handles connection failures and integrates well with CI environments. The current version is 2.1.0, and releases occur infrequently but with critical fixes and Python version support.

Warnings

Install

Imports

Quickstart

This example demonstrates how to set up a remote PDB session that listens on a specified host and port. The `set_trace()` call will block execution until a `telnet` client connects. For Python 3.7+, you can also use the built-in `breakpoint()` by setting the `PYTHONBREAKPOINT=remote_pdb.set_trace` environment variable, along with `REMOTE_PDB_HOST` and `REMOTE_PDB_PORT` for configuration.

import os
from remote_pdb import RemotePdb

REMOTE_HOST = os.environ.get('REMOTE_PDB_HOST', '127.0.0.1')
REMOTE_PORT = int(os.environ.get('REMOTE_PDB_PORT', 4444))

def my_function():
    print("Entering my_function...")
    # This will block until a client connects
    RemotePdb(host=REMOTE_HOST, port=REMOTE_PORT).set_trace()
    print("Exiting my_function.")

if __name__ == '__main__':
    print(f"Starting script. Remote PDB will listen on {REMOTE_HOST}:{REMOTE_PORT}.")
    print("Connect with: telnet " + REMOTE_HOST + " " + str(REMOTE_PORT))
    my_function()
    print("Script finished.")

# To run and connect:
# 1. Start your Python script (e.g., python your_script.py)
# 2. In another terminal, connect: telnet 127.0.0.1 4444 (or custom host/port)

view raw JSON →