Remote Debugging

Feb 16, 2012 at 3:50 PM

I apologize if this should have gone into any of the other (relatively few) remote debugging discussions here, but I felt that the problems I'm having might be slightly different than the others'.

I have a scenario where I run python scripts locally and want them to break into the debugger (Like c++ apps do) at the correct line and with the proper state. I do NOT want to "attach to process" manually, since that requires manual interaction at a precise time (which is impossible with 100's of scripts running in a fast pace).

To compare with, I got this working perfectly with Eclipse and PyDev. The main difference there, I guess, is that then you start a python debugging server which simply waits for connections. The reason I ask for this is that some people at work like the Msvs IDE/debugger more that Eclipse's, and I'd like to offer them both, with minimal effort, to get more people on the Python train :)

I would love for PTVS to have the same functionality. This is how I invoke the client script with in the Pythonpath:

> python -m pydevd --port 5678 --client --file arg1 arg2 etc

I really like that approach since that, like cProfile, it's non intrusive to your own scripts. You get remote debugging "for free".


Am I missing something, is this already possible with PTVS today?

If not, is this something you plan to do, or at least think is valid enough to add to the task list?


Regards, Mathias Westerdahl


Related issue (but not exactly the same)

Feb 16, 2012 at 4:40 PM

Also potentially related but still not exactly the same:

You're correct in that there's currently no support for this.  It's something in the back of my mind but I don't think we have an issue tracking it.  Can you open one?

One comment on attach to process is that the timing there doesn't (or shouldn't matter).  As long as the interpreter is initialized we can attach, you can set the breakpoint, and it'll be hit at the appropriate time.  The only real downside is when you can't attach quickly to hit breakpoints on startup.  But for the startup reason alone, and I'm sure there's more, we should support this style of debugging.


Jan 25, 2013 at 10:21 PM
Edited Jan 25, 2013 at 10:21 PM

Hi Mathias,

Can you take a look at the remote debugging API that we intend to support in PTVS 2.0 here: - and see if it will cover your scenario? It's not quite the same as you've described, and it's invasive in that it requires a code change, but it would let you enable attaching debugger to your processes remotely (or locally), and blocking their execution until such time the debugger is attached. It also has the ability to explicitly signal a breakpoint from the script.