Breakpoints in a QThread are not caught

Answered
I am using Pycharm 3.1.1.  PyCharm is not catching breakpoints in a QThread.  It catches breakpoints in the __init__ section of the thread, but not in def run.  Of course, the breakpoints are enabled and have suspend checked.  I can put a breakpoint on a print statement.  I see the result of the print statement in the Console, but the breakpoint is not triggered and the program does not suspend.  

Anyone have any ideas what is going on?
8 comments
Comment actions Permalink
Here is PyCharm Debug output:

/usr/local/bin/python3.3 "/Applications/PyCharm CE.app/helpers/pydev/pydevd.py" –multiproc –client 127.0.0.1 –port 49845 –file /Users/Clark/PycharmProjects/RadioMemoryEditor/Main.py
Started in multiproc mode

('Connecting to ', '127.0.0.1', ':', '49845')
('Connected.',)
received >>99    -1    49846
<<

Received command: >>99    -1    49846<<

Received port 49846

pydev debugger: process 1174 is connecting

('Connecting to ', '127.0.0.1', ':', '49846')
('Connected.',)
Connected to pydev debugger (build 133.881)
received >>501    1    0.1    UNIX
<<

Received command: >>501    1    0.1    UNIX<<

sending cmd: CMD_VERSION 501    1    %40%40BUILD_NUMBER%40%40

received >>111    3    python-line    /Users/Clark/PycharmProjects/RadioMemoryEditor/Main.py    400    None    None
<<

Received command: >>111    3    python-line    /Users/Clark/PycharmProjects/RadioMemoryEditor/Main.py    400    None    None<<

Added breakpoint:/Users/Clark/PycharmProjects/RadioMemoryEditor/Main.py - line:400 - func_name:None

received >>111    5    python-line    /Users/Clark/PycharmProjects/RadioMemoryEditor/dialogRadioSelect.py    128    None    None
122    7    BaseException    0    1
101    9    
<<

Received command: >>111    5    python-line    /Users/Clark/PycharmProjects/RadioMemoryEditor/dialogRadioSelect.py    128    None    None<<

Added breakpoint:/Users/Clark/PycharmProjects/RadioMemoryEditor/dialogRadioSelect.py - line:128 - func_name:None

Received command: >>122    7    BaseException    0    1<<

Exceptions to hook on terminate: {'BaseException': <pydevd_breakpoints.ExceptionBreakpoint object at 0x109de2fd0>}

Received command: >>101    9    <<

sending cmd: CMD_THREAD_CREATE 103    2    <xml><thread name="pydevd.reader" id="-1"/></xml>

sending cmd: CMD_THREAD_CREATE 103    4    <xml><thread name="pydevd.writer" id="-1"/></xml>

Registered Kenwood_TH-D7 = THD7Radio
Registered Kenwood_TH-D7G = THD7GRadio
Registered Kenwood_TM-D700 = TMD700Radio
Registered Kenwood_TM-V7 = TMV7Radio
Registered Kenwood_TM-G707 = TMG707Radio
Registered Kenwood_TH-G71 = THG71Radio
Registered Kenwood_TH-F6 = THF6ARadio
Registered Kenwood_TH-F7 = THF7ERadio
Registered Kenwood_TM-D710 = TMD710Radio
Registered Kenwood_TH-D72_live_mode = THD72Radio
Registered Kenwood_TM-V71 = TMV71Radio
Registered Kenwood_TH-K2 = THK2Radio
Registered Kenwood_TM-271 = TM271Radio
Registered Kenwood_TM-471 = TM471Radio
Registered Icom_7200 = Icom7200Radio
Registered Icom_7000 = Icom7000Radio
Registered Icom_746 = Icom746Radio
Registered Alinco_DR03T = DR03Radio
Registered Alinco_DR06T = DR06Radio
Registered Alinco_DR135T = DR135Radio
Registered Alinco_DR235T = DR235Radio
Registered Alinco_DR435T = DR435Radio
Registered Alinco_DJ596 = DJ596Radio
Registered Jetstream_JT220M = JT220MRadio
Registered Alinco_DJ175 = DJ175Radio
Registered AnyTone_5888UV = AnyTone5888UVRadio
Registered Intek_HR-2040 = IntekHR2040Radio
Registered Polmar_DB-50M = PolmarDB50MRadio
Registered Powerwerx_DB-750X = PowerwerxDB750XRadio
Registered Baofeng_UV-3R = UV3RRadio
Registered Baofeng_UV-5R = BaofengUV5R
Registered Baofeng_F-11 = BaofengF11Radio
Registered Baofeng_UV-82 = BaofengUV82Radio
Registered Baojie_BJ-UV55 = BaojieBJUV55Radio
Registered Yaesu_FT-1802M = FT1802Radio
Registered Yaesu_FT-2800M = FT2800Radio
Registered Yaesu_FT-60 = FT60Radio
Registered Yaesu_FT-7800_7900 = FT7800Radio
Registered Yaesu_FT-8800 = FT8800Radio
Registered Yaesu_FT-8900 = FT8900Radio
Registered Yaesu_FT-817 = FT817Radio
Registered Yaesu_FT-817ND = FT817NDRadio
Registered Yaesu_FT-817ND_US = FT817NDUSRadio
Registered Yaesu_FT-857_897 = FT857Radio
Registered Yaesu_FT-857_897_US = FT857USRadio
Registered Yaesu_FT-90 = FT90Radio
Registered Yaesu_FTM-350 = FTM350Radio
Registered Generic_CSV = CSVRadio
Registered Commander_KG-UV = CommanderCSVRadio
Registered RT_Systems_CSV = RTCSVRadio
Registered ARRL_Travel_Plus = TpeRadio
Registered Baofeng_BF-888 = H777Radio
Registered Icom_IC-208H = IC208Radio
Registered Icom_IC-2100H = IC2100Radio
Registered Icom_IC-2200H = IC2200Radio
Registered Icom_IC-2720H = IC2720Radio
Registered Icom_IC-2820H = IC2820Radio
Registered Icom_IC-91_92AD = IC9xRadio
Registered Icom_IC-91_92AD_ICF_File = IC9xICFRadio
Registered Icom_IC-Q7A = ICQ7Radio
Registered Icom_IC-T70 = ICT70Radio
Registered Icom_IC-T7H = ICT7HRadio
Registered Icom_IC-T8A = ICT8ARadio
Registered Icom_IC-W32A = ICW32ARadio
Registered Icom_IC-V82_U82 = ICx8xRadio
Registered Icom_ID-31A = ID31Radio
Registered Icom_ID-51A = ID51Radio
Registered Icom_ID-800H_v2 = ID800v2Radio
Registered Icom_ID-880H = ID880Radio
Registered Icom_ID-80H = ID80Radio
Registered Kenwood_HMK = HMKRadio
Registered Kenwood_ITM = ITMRadio
Registered Puxing_PX-777 = Puxing777Radio
Registered Puxing_PX-2R = Puxing2RRadio
Registered TYT_TH-UV3R = TYTUV3RRadio
Registered TYT_TH-UVF8D = TYTUVF8DRadio
Registered Kenwood_TH-D72_clone_mode = THD72Radio
Registered TYT_TH-UVF1 = TYTTHUVF1Radio
Registered Kenwood_TK-7102 = KenwoodTK7102Radio
Registered Kenwood_TK-8102 = KenwoodTK8102Radio
Registered Kenwood_TK-7108 = KenwoodTK7108Radio
Registered Kenwood_TK-8108 = KenwoodTK8108Radio
Registered Kenwood_TS-2000 = TS2000Radio
Registered Baofeng_UV-B5 = BaofengUVB5
Registered Yaesu_VX-2 = VX2Radio
Registered Yaesu_VX-3 = VX3Radio
Registered Yaesu_VX-5 = VX5Radio
Registered Yaesu_VX-6 = VX6Radio
Registered Yaesu_VX-7 = VX7Radio
Registered Yaesu_VX-8_R = VX8Radio
Registered Yaesu_VX-8_DR = VX8DRadio
Registered Yaesu_VX-8_GE = VX8GERadio
Registered Vertex_Standard_VXA-700 = VXA700Radio
Registered Wouxun_KG-UVD1P = KGUVD1PRadio
Registered Wouxun_KG-UV6 = KGUV6DRadio
Registered Wouxun_KG-816 = KG816Radio
Registered Wouxun_KG-818 = KG818Radio
initializing
sending cmd: CMD_THREAD_CREATE 103    6    <xml><thread name="MainThread" id="pid1174_seq2" /></xml>

User selected TYT TH-UVF1 on port /dev/cu.PL2303-00001004
Clone thread started   COMMENT:  I PUT A BREAKPOINT ON THE PRINT STATEMENT THAT PRINTED THIS LINE
Clone thread ended
memory
sending cmd: CMD_THREAD_SUSPEND 105    8    <xml><thread id="pid1174_seq2" stop_reason="111" message="None"><frame id="4517145536" name="cb_clonein" file="/Users/Clark/PycharmProjects/RadioMemoryEditor/Main.py" line="400">"</frame><frame id="4517507152" name="main" file="/Users/Clark/PycharmProjects/RadioMemoryEditor/Main.py" line="415">"</frame><frame id="140623176804496" name="%26lt%3Bmodule%26gt%3B" file="/Users/Clark/PycharmProjects/RadioMemoryEditor/Main.py" line="418">"</frame><frame id="140623176807632" name="execfile" file="/Applications/PyCharm CE.app/helpers/pydev/_pydev_execfile.py" line="37">"</frame><frame id="140623176800432" name="run" file="/Applications/PyCharm CE.app/helpers/pydev/pydevd.py" line="1145">"</frame><frame id="140623164740320" name="%26lt%3Bmodule%26gt%3B" file="/Applications/PyCharm CE.app/helpers/pydev/pydevd.py" line="1534">"</frame></thread></xml>

received >>114    11    pid1174_seq2    4517145536    FRAME
<<

Received command: >>114    11    pid1174_seq2    4517145536    FRAME<<

('NOT processing internal command ', '<pydevd_comm.InternalGetFrame object at 0x113428150>')
('processing internal command ', '<pydevd_comm.InternalGetFrame object at 0x113428150>')
sending cmd: CMD_GET_FRAME 114    11    <xml><var name="emsg" type="RadioError" value="RadioError%253A No error" isContainer="True" />%0A<var name="radio" type="TYTTHUVF1Radio" value="TYTTHUVF1Radio%253A %253Cchirp.thuv1f.TYTTHUVF1Radio object at 0x113409640%26gt%3B" isContainer="True" />%0A<var name="self" type="MyApplication" value="MyApplication%253A %253C__main__.MyApplication object at 0x10d4cb218%26gt%3B" isContainer="True" />%0A</xml>
0
Comment actions Permalink
I will try to create a small sample project that demonstrates this problem.
0
Comment actions Permalink
Here is a simple program that demonstrates the problem:

from PyQt5 import QtCore
import time
import sys

  1. How to show problem with breakpoints
    # Put breakpoints on lines 17, 20, 31, 34, 46, and 49
    # Run usingQThread(), usingMoveToThread(), and usingQRunnable()
    # Observe no breakpoints are hit


  1. Subclassing QThread
class AThread(QtCore.QThread):

    def run(self):
        print("Using QThread")
        count = 0
        while count < 5:
            time.sleep(1)
            print("Increasing")
            count += 1

  1. Subclassing QObject and using moveToThread
class SomeObject(QtCore.QObject):

    finished = QtCore.pyqtSignal()

    def longRunning(self):
        print("Using MoveToThread")
        count = 0
        while count < 5:
            time.sleep(1)
            print("Increasing")
            count += 1
        self.finished.emit()

  1. Using a QRunnable
class Runnable(QtCore.QRunnable):

    def run(self):
        print("Using QRunnable")
        count = 0
        app = QtCore.QCoreApplication.instance()
        while count < 5:
            print("Increasing")
            time.sleep(1)
            count += 1
        app.quit()


def usingQThread():
    app = QtCore.QCoreApplication([])
    thread = AThread()
    thread.finished.connect(app.exit)
    thread.start()
    sys.exit(app.exec_())

def usingMoveToThread():
    app = QtCore.QCoreApplication([])
    objThread = QtCore.QThread()
    obj = SomeObject()
    obj.moveToThread(objThread)
    obj.finished.connect(objThread.quit)
    objThread.started.connect(obj.longRunning)
    objThread.finished.connect(app.exit)
    objThread.start()
    sys.exit(app.exec_())

def usingQRunnable():
    app = QtCore.QCoreApplication([])
    runnable = Runnable()
    QtCore.QThreadPool.globalInstance().start(runnable)
    sys.exit(app.exec_())

if __name__ == "__main__":
    #usingQThread()
    #usingMoveToThread()
    #usingQRunnable()
0
Comment actions Permalink
Should I report this as a bug?  What do I need to do to get someone to respond about this?  If others can reproduce this, it seems like a rather serious bug. Would one of you try my simple python program and see if your breakpoints are hit?
0
Comment actions Permalink
Yes I have the same problem and an open support ticket right now, I will reference them to this post. Seems like the forums here are a bit dead.
0
Comment actions Permalink

Does anyone know if breakpoints are now caught in PyCharm QThread ?

0
Comment actions Permalink

bueller? anyone?

 

In all seriousness, this still seems to be an issue.

0

Please sign in to leave a comment.