How to close a thread from within?

When you start a thread, it begins executing a function you give it (if you’re extending threading.Thread, the function will be run()). To end the thread, just return from that function.

According to this, you can also call thread.exit(), which will throw an exception that will end the thread silently.

Leave a Comment