Author ncoghlan
Recipients Jurko.Gospodnetić, eric.araujo, georg.brandl, ncoghlan, terry.reedy
Date 2010-12-12.02:22:12
SpamBayes Score 0.0
Marked as misclassified No
Message-id <>
I have a slightly better fix for that coming soon. There's a subtle race condition in the proposed approach that can lead to the temporary dir not being deleted if an asynchronous exception, such as KeyboardInterrupt, arrives after mkdtemp completes successfully, but before _closed is set back to False.

Instead, the new init code will look like:

        self._closed = False = None # Handle mkdtemp throwing an exception = mkdtemp(suffix, prefix, dir)

And the cleanup condition will be gated on being set as well as on _closed being False. I believe there is still a window where mkdtemp successfully creates the directory, but never gets set, but we want to make that window as small as possible.

I also realised this should be emitting a ResourceWarning from __del__, as well catching the errors and shut down and turning them into something more meaningful on sys.stderr.

The attached patch won't quite apply cleanly, since it predates r87172
Date User Action Args
2010-12-12 02:22:16ncoghlansetrecipients: + ncoghlan, georg.brandl, terry.reedy, eric.araujo, Jurko.Gospodnetić
2010-12-12 02:22:16ncoghlansetmessageid: <>
2010-12-12 02:22:13ncoghlanlinkissue10188 messages
2010-12-12 02:22:13ncoghlancreate