Is it good practice to exit a thread manually in python?
<p>Is it good practice to exit a thread manually? The below code has commented #sys.exit() because I assume the thread ends there. But is it good practice to end it anyway? If not, is there any overhead created if that thread is called hundres of times without manually exiting with sys.exit()?</p>

<pre><code>import time
import threading
import sys

def non_daemon():
    print('Test non-daemon')
    time.sleep(5)
    #sys.exit() # is this necessary/encouraged?

t = threading.Thread(name='non-daemon', target=non_daemon)
t.start()

print("done")
</code></pre>

<p><code>sys.exit()</code> has nothing to do with threads. As <a href="https://docs.python.org/3/library/sys.html#sys.exit" rel="nofollow">the docs</a> explain, it only has an effect when called from the main thread. In all other cases, all it does is raise an exception. There's absolutely no reason to call it in a thread.</p>

python multithreading