I am a newbie in python programming, what I understand is that a process can be a daemon, but a thread in a daemon mode, I couldn’t understand the usecase of this, I would request the python gurus to help me in understanding this.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is some basic code using threading:
When you run it, you get
Now comment out the line:
Run it again, and you’ll see that the script prints the same result, but hangs.
The main thread ends (note that
got herewas printed), but the second thread never finishes.In contrast, when
t.daemonis set toTrue, the threadtis terminated when the main thread ends.Note that “daemon threads” has little to do with daemon processes.