A
A
Arseniy Khusainov2021-08-12 19:38:33
Python
Arseniy Khusainov, 2021-08-12 19:38:33

How can a Thread be stopped in python?

How can a Thread be stopped in python without using join?
Example:

from threading import Thread
class Test:
    def __init__(self):
        self.run=True
        Thread(target=self.test).start()
    def test(self):
        #something

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0ralo, 2021-08-12
@halwarsing

The thread cannot be stopped. You can constantly check the stop point in the loop and stop the task if it is active. But the only way to kill a thread is to terminate the program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question