1
votes

While going through the python docs for thread objects it had a note on daemon threads wherein it said:

Daemon threads are abruptly stopped at shutdown. Their resources (such as open files, database transactions, etc.) may not be released properly. If you want your threads to stop gracefully, make them non-daemonic and use a suitable signalling mechanism such as an Event.

So why do we use them ?

1

1 Answers

2
votes

Python tries to join non-daemon threads at exit. If you haven't implemented a mechanism to terminate them, python will hang. Annoyingly, ctrl-C typically doesn't work and you have to kill the program externally.