Multithreaded python application doesn't hit breakpoints in Visual Studio

I am currently developing a PyQt application in Visual Studio. Debugging works fine until I decided that my user interface is responsive by moving stuff to a workflow with Qt threads.

class MainWindow(base, form):

    start_work = QtCore.pyqtSignal()

    def __init__(self, parent=None):
        # Create a seperate thread in which the update information is polled.
        self.thread = QtCore.QThread()
        # Create Worker object and move it to new thread
        self.worker = Worker()
        self.worker.moveToThread(self.thread)
        # connect signal to start work in the extra tread
        self.start_work.connect(self.worker.get_work_done)
        self.thread.start()

    #function emit a signal to start doing the work
    def do_work(self):
        self.startWork.emit()

Any function called on my work object connects through signal slots

class Worker(QtCore.QObject):
    @QtCore.pyqtSlot()
    def get_work_done(self):
        #lets do some time consuming work.

The code is working fine. The only problem now, I can’t debug everything that happens inside get_work_done. The visual studio will not break at these control points.

When I open any function MainWindow, Visual Studio Debugger shows only one thread. It does not seem to be aware of any other threads created by the application.

+4
2

, ( , ..). Python _thread. - , , , Qt , .

threading QThread , .

+1

, , Python, PTVS. QThread, :

import pydevd;pydevd.settrace(suspend=False)

: Python?

0

All Articles