[Tutor] help with Tkinter, please

Kent Johnson kent37 at tds.net
Tue Nov 28 12:10:21 CET 2006

wesley chun wrote:
>>> "The entire Python program exits when no active non-daemon threads
>>> are left."
>> why do you recommend the use of daemons here?
>> Wouldn't that just leave a load of silently running daemon
>> threads eating up resources after the main program finishes?
>> I don't see the logic of that one? I'd have thought you wanted
>> to be sure all application threads died when the app died?
>> What am I missing?
> are you missing something?  :-) i think there is a distinction bewteen
> a daemon/server process and daemon threads.  i don't think that daemon
> threads are spawned to a different process, save perhaps the ones
> started from C.
> i believe that as soon as there are only daemon threads left (a
> complementary statement to the doc line above for Thread objects), the
> Python interpreter will exit, killing them all. i think Python threads
> are very similar to Java threads, but i'll let the thread experts
> chime in here.

Yes, that is correct. Daemon threads won't block the program from 
exiting. They will be stopped when the program exits - they are not 
separate processes.

However for the OP's application which is running calculations in the 
background in a GUI application, the threads will probably be created as 
needed and will end when the calculation is done. Unless the calculation 
is long enough that you want to be able to exit the app before the 
calculation completes, the thread doesn't really need to be a daemon.


More information about the Tutor mailing list