Impediments with using PEP 768's remote debugging - and announcing a helper tool for it

[Note: This is not an ask for personal help in using python; I am posting here because DPO seems like a useful place for this and there is no category for announcing 3rd-party projects.]

When PEP 768 “Safe external debugger interface for CPython” was released in Python 3.14, I was excited by this feature! I could see it being useful both in my personal coding, and in situations I regularly deal with at work where debugging is a pain. Not to mention, it’s very cool :slight_smile: However when I went to experiment with it, I found that my python -m pdb --pid <number> command was immediately stopped short with a permission error.

Turns out, a system setting on my Linux OS restricts which processes can attach to others. The details are that I must either attach as root - which is probably ok for personal use but generally not possible in the environment at work - or I can attach only to a child process or one that’s given my specific process permission. I figured out a way to make the latter approach work by launching the process of interest from a Python REPL session, and then when I wanted to pause it and drop into the debugger, attaching from the same session. IMO, this is pretty awkward, especially for long-running jobs: the originating session must be kept open for as long as you might need to debug the job! If you ever lose that terminal, you lose the access to debug.

This is why I came up with another method and created a small tool that does process management and communication for you, to enable a user-friendly way of running python scripts and then dropping into a pdb session whenever you want, without root permissions. I’m posting to let people know about this tool which I nicknamed helicopter-parent, and to gauge interest in the idea of such a tool, or even find out if there is a reason I missed why this is issue is not significant. You are welcome to comment on what I described here, or try it out yourself! (It is in very basic state, but it does have a test suite.) Let me know what you think.

2 Likes