[PyQt] Debugging multithreaded code
Håkon Bertheussen
haakon.bertheussen at gmail.com
Sat Feb 28 15:48:05 GMT 2009
I'm having a problem with debugging a piece of code that's being run
in a separate QThread. Specifically, any breakpoints I set in this
code will not be triggered. I've tried with both PyDev and pdb. This
is on Windows using Python 2.6.1 and PyQt 4.4.4.
See below for an example:
(main.py)
from PyQt4.Qt import *
import signal
class MyThread(QThread):
def run(self):
print "Hello World" # attempting to break at this line
def main():
app = QApplication([])
signal.signal(signal.SIGINT, signal.SIG_DFL) # exit on ctrl-c
thread = MyThread()
thread.start() # prints "Hello World", but no breakpoint encountered!
return app.exec_()
if __name__=='__main__':
main()
-------
Testing with pdb:
C:\pytest\src>python -m pdb main.py
> c:\pytest\src\main.py(1)<module>()
-> from PyQt4.Qt import *
(Pdb) b 6
Breakpoint 1 at c:\users\haakon\workspace\pytest\src\main.py:6
(Pdb) c
Hello World
^C
C:\pytest\src>
-------
As you can see, the breakpoint never triggered. I can set breakpoints
on code that runs in the main thread just fine.
More information about the PyQt
mailing list