Why aren't breakpoints working on the Swing Event Dispatch Thread in PyDev?
Question: I'm using Jython, Swing, and PyDev (Eclipse).

Breakpoints are not being hit on any code that runs on the EDT (aka AWT Event
Queue?).

This includes:

  * Functions that are invoked from a Swing event (eg JButton click)
  * Functions that, via a decorator, are run through `SwingUtilities.invokeLater()` (See the last example [here](http://wiki.python.org/jython/ADB%20SwingExamples#Decorator_to_add_a_function_to_SwingUtilities.invokeLater_donated_by_Alex_Gr.2BAPY-nholm).
  * Functions that registered as hooks to a Java package (socket class), that I'm using.

**Swing event code to reproduce:**

    
    
    from javax.swing import JFrame, JButton
    
    def TestFunc(event):
        #breakpoints in this function don't work
        print "Hey"
    
    if __name__ == '__main__':
        mainWindow = JFrame('Test', 
                            defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                            size = (1024, 600))
        mainWindow.add(JButton("Hey", actionPerformed = TestFunc))
        mainWindow.visible = True
    

**invokeLater() code to reproduce:**

    
    
    from java.lang import Runnable
    from javax.swing import SwingUtilities
    import threading
    
    class foo(Runnable):
        def __init__(self, bar):
            self.bar = bar
    
        def run(self):
            #breakpoints in this function don't work
            print threading.currentThread()
            print self.bar
    
    if __name__ == '__main__':
        myFoo = foo(5)
        SwingUtilities.invokeLater(myFoo)
    


Answer: It's actually a Jython issue.

I.e.: in the code below, when TestFunc is called, the print from the
trace_dispatch should be called, but it's not.

So, the Jython tracing implementation is not calling the tracing function as
it should in that situation. You can 'help' the PyDev debugger by calling
`import pydevd;pydevd.settrace(suspend=False)` so that the debugger discovers
about that frame (i.e.: in the start of TestFunc add that line of code).

Note that if you don't pass the suspend=False, it'll act as a breakpoint in
the code and will stop the execution at that line.

    
    
    import sys
    import threading
    def trace_dispatch(frame, event, arg):
        print frame.f_code.co_filename, frame.f_code.co_name
    sys.settrace(trace_dispatch)
    threading.settrace(trace_dispatch)
    
    from javax.swing import JFrame, JButton
    
    def TestFunc(event):
        print "Hey"
    
    if __name__ == '__main__':
        mainWindow = JFrame('Test', 
                            defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                            size = (1024, 600))
        mainWindow.add(JButton("Hey", actionPerformed = TestFunc))
        mainWindow.visible = True
    

