daemon thread cleanup approach

Carl Banks pavlovevidence at gmail.com
Thu May 29 15:40:37 EDT 2014


On Thursday, May 29, 2014 1:15:35 AM UTC-7, Chris Angelico wrote:
> On Thu, May 29, 2014 at 11:20 AM, Carl Banks <pavlovevidence at gmail.com> wrote:
> 
> > Most threads have cleanup work to do (such as deleting temporary directories and killing spawned processes).
> 
> >
> 
> > For better or worse, one of the requirements is that the library can't cause the program to hang no matter what...
> 
> 
> 
> This ma y be a fundamental problem. I don't know how Windows goes with
> 
> killing processes (can that ever hang?), but certainly you can get
> 
> unexpected delays deleting a temp dir, although it would probably
> 
> require some deliberate intervention, like putting your %temp% on a
> 
> remote drive and then bringing that server down. But believe you me,
> 
> if there is a stupid way to do something, someone WILL have done it.
> 
> (Have you ever thought what it'd be like to have your
> 
> swapfile/pagefile on a network drive? I mean, there's acres of room on
> 
> the server, why waste some of your precious local space?)
> 
> 
> 
> So you may want to organize this as a separate spin-off process that
> 
> does the cleaning up.
[snip rest]


Thanks, that's good information.  Even if the temp directories do fail to be removed before the join times out (which probably won't happen much) the situation is still no worse than the situation where the daemon thread is just killed without any chance to clean up.

And subprocesses would be a more reliable way to ensure cleanup and might be the direction I take it in the future.

Carl Banks



More information about the Python-list mailing list