pdb-attach is a Python debugger extension that allows users to attach to already running Python processes. Unlike standard `pdb.set_trace()`, it facilitates debugging long-running or unresponsive applications by enabling remote connection. It's currently at version 3.0.1 and appears to be actively maintained, with a focus on POSIX-compliant operating systems.
pip install pdb-attachVerified import paths — ran on the pinned version, not inferred.
To use `pdb-attach`, the target Python program must first be modified to call `pdb_attach.listen()` at the desired point where debugging should be enabled. This function sets up a listening socket. Then, from a separate terminal, the `pdb_attach` command-line tool is used with the target process's PID and the specified port to initiate a debugging session.
Use a POSIX-compliant OS (Linux, macOS) for `pdb-attach`, or explore alternative debugging tools for Windows.
Modify the target application's code to include `from pdb_attach import listen; listen(port=<some_port>)` at the point where you wish to enable attachment.
Only use `pdb-attach` in secure, controlled environments. Be aware of the risks when debugging processes on machines with untrusted access.
Be cautious when using in multi-threaded contexts. Consider alternative debugging strategies or carefully test its behavior with your specific multi-threaded code.
Avoid using `pdb-attach` across container/host boundaries. Debug processes within the same container or on the host directly.
Install the package using pip: `pip install pdb-attach`
Ensure `import pdb_attach; pdb_attach.listen()` is explicitly called within the Python program you intend to debug. Confirm the target process is running on a POSIX-compliant operating system. Verify the correct PID and port are used, and check any firewall rules that might prevent the connection.
Run the `pdb-attach` command with elevated privileges (e.g., `sudo pdb-attach --pid <PID>`) or configure your operating system's `ptrace` settings to allow non-root debugging (e.g., by modifying `/proc/sys/kernel/yama/ptrace_scope` on Linux, though this has security implications).
No dependency data recorded yet.