I’m working with Pydev’s Remote Debugger and Eclipse and I have a problem with multi-thread Python applications. The remote debugger only traces the MainThread and the breakpoints it has, but if I try to add a breakpoint to a different thread it doesn’t stop.
If I put a breakpoint on the “print hello” line and another one on the “print bye” line, the debugger only stops on the “print bye” line, which belongs to the main thread.
How could I make the debugger to trace the new thread and stop on its breakpoints?
I have tried putting another settrace() entry just below the run definition and the debugging works fine, but that is something I would like to avoid. Is there any piece of code (from pydevd.py or any other file) I should change to achieve what I have explained?
Thanks in advance.
Kind regards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all,
I’m working with Pydev’s Remote Debugger and Eclipse and I have a problem with multi-thread Python applications. The remote debugger only traces the MainThread and the breakpoints it has, but if I try to add a breakpoint to a different thread it doesn’t stop.
I’ve written a simple piece of code to test it:
If I put a breakpoint on the “print hello” line and another one on the “print bye” line, the debugger only stops on the “print bye” line, which belongs to the main thread.
How could I make the debugger to trace the new thread and stop on its breakpoints?
I have tried putting another settrace() entry just below the run definition and the debugging works fine, but that is something I would like to avoid. Is there any piece of code (from pydevd.py or any other file) I should change to achieve what I have explained?
Thanks in advance.
Kind regards.
To make debug active on all threads, use the code below.
import pydevd
pydevd.settrace(suspend=False)
import threading
threading.settrace(pydevd.GetGlobalDebugger().trace_dispatch)
another option would be having pydevd.settrace(suspend=False) called on the constructor of each new Thread.
Cheers,
Fabio
Thanks for the quick answer Fabio, it is working now.