, thread ( _thread Python 3), , thread.exit().
:
( , ) , , join() , .
:
class MyThread(threading.Thread):
def __init__(self):
super(MyThread, self).__init__()
self._stop_req = False
def run(self):
while not self._stop_req:
pass
def stop(self):
self._stop_req = True;
def main():
processing_thread = MyThread()
processing_thread.start()
processing_thread.stop()
processing_thread.join()
if __name__ == "__main__":
main()