daemon thread cleanup approach

Ethan Furman ethan at stoneleaf.us
Fri May 30 16:59:55 EDT 2014


On 05/30/2014 01:47 PM, Devin Jeanpierre wrote:
>
> Don't use daemon threads, they are inherently un-thread-safe: any
> global access you do anywhere inside a daemon thread can fail, because
> daemon threads are still potentially run during interpreter shutdown,
> when globals are being deleted from every module. Most functions you
> might call are not safe in a daemon thread at shutdown.

Given the use-case (must shut down, cannot risk a hung process, orphan files be damned) I don't think having a daemon 
thread die because it raised an exception trying to access a missing global is a big deal.

--
~Ethan~



More information about the Python-list mailing list