How to start/stop or pause running threads?

Heads up! You've already completed this tutorial.

Pshemas | 2020-05-11 07:17:31 UTC | #1

Nice article. I have question, it is possible use this template for function which we start by pressing button and break by pressing another button?

https://www.pythonguis.com/courses/concurrent-execution/multithreading-pyqt-applications-qthreadpool/


anonymous | 2020-05-10 21:32:56 UTC | #2

I would like to ask for help with stopping thread (as Pshemas did some time ago). I have tried to add signal stop but I do not know how to emit that.


Alex | 2020-05-11 07:16:33 UTC | #3

I wrote a program using this article. But I do not know how to pause or stop all processes. Please, help.


luciano | 2020-05-11 07:18:18 UTC | #4

Hi, I'm working on a data sample and plot GUI, which communicates with an external device, I've read the tutorial and helps me a lot. The issue is how to handle start and stop QRunnable in follow to start and stop communication engine.


Steven_K_Peters | 2020-11-16 20:54:11 UTC | #5

In my code, my thread uses a while loop. So what I did is I created a variable called self.active = True inside class Worker which is used to control the while loop (while active). When I want the loop to stop I simply call worker.active=False and I make sure to set worker.setAutoDelete(True) so the thread is deleted automatically upon exit.

To make a thread pause I'm thinking you could place a while loop with argument self.pause=True. while self.pause: time.sleep(1)

I'm not sure if you would like my pause solution, but it's an option.


martin | 2020-11-16 20:54:11 UTC | #6

There is a working example of Steven's idea on this topic with a pause/resume/stop methods added to the worker.


Over 10,000 developers have bought Create GUI Applications with Python & Qt!

To support developers in [[ countryRegion ]] I give a [[ localizedDiscount[couponCode] ]]% discount with the code [[ couponCode ]] — Enjoy!

For [[ activeDiscount.description ]] I'm giving a [[ activeDiscount.discount ]]% discount with the code [[ couponCode ]] — Enjoy!

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak