Reputation: 444
I've been learning about multi-threading, specifically in the context of a PyQt 5 application.
Initially I implemented a version using 'threading', but have since learnt that I should be using 'QThread' to allow use of signals / slots, e.g:
workerThread = QThread()
workerObject = Worker(cmdlist)
workerObject.moveToThread(workerThread)
workerThread.started.connect(workerObject.run)
workerObject.finished.connect(workerThread.quit)
However, is it possible to design a system in which:
An example of the behaviour would be this:
thread = threading.Thread(target=self.run, args=())
But how would I implement similar behaviour with QThread?
Or my understanding of threads in Python in-correct?
Upvotes: 3
Views: 13854
Reputation: 934
Martin Fitzpatrick has an amazing guide on how to do this using QThreadPools. I think this is what you're looking for.
Multithreading PyQt applications with QThreadPool
Upvotes: 3