Not sure whether it's the right way to ask. I will just show you guys some code. Say I write some a simple python script:
#!/usr/bin/python3
import threading
from time import sleep
def echo_num(num):
sleep(1)
print('the number is', num)
if __name__ == '__main__':
threads = []
for i in range(10):
t = threading.Thread(target=echo_num, args=(i,), daemon=None)
threads.append(t)
for t in threads:
t.start()
the script exits after all the threads end. After reading the threading-doc I found:
A thread can be flagged as a “daemon thread”. The significance of this flag is that the entire Python program exits when only daemon threads are left. The initial value is inherited from the creating thread.
If the script is daemon(therefore the called threads are also daemon), the called threads should not print anything.
So I assume the python script is by default not daemon?