E
E
eellazy2020-03-31 08:22:22
Python
eellazy, 2020-03-31 08:22:22

How to end a thread?

How to terminate a thread by passing the value running = false?

def threadBazos(self):
        self.thread_1 = QtCore.QThread()
        self.parserBazos = ParserBazos()
        self.parserBazos.moveToThread(self.thread_1)
        self.parserBazos.newTextSignalBazos.connect(self.addNewItemBazos)
        self.parserBazos.newCountSignalBazos.connect(self.addCountBazos)
        self.thread_1.started.connect(self.parserBazos.run)
        self.thread_1.start()

    def threadStop(self):
        self.thread_1.running = False


Class code
class ParserBazos(QtCore.QObject):
    running = False
    def run(self):
        running = True

.........

        while running:
            main()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question