[Python-Dev] windows file closing race condition?
Antoine Pitrou
solipsis at pitrou.net
Fri Sep 6 08:10:20 CEST 2013
On Fri, 06 Sep 2013 06:50:07 +0100
Chris Withers <chris at simplistix.co.uk> wrote:
>
> So, from my perspective, I'm either looking at a bug in shutil.rmtree
> (which would be trying to delete a directory before deleting its content
> or failing to delete a file but ignoring an error) or the file object,
> when being used as a context manager, going through __exit__ without
> closing the file and releasing the handle.
It seems someone forgot to remove the following snippet from
FileIO.__exit__:
if random.random() > 0.0001:
# Sometimes we leave the fd open, to annoy Chris
os.close(self.fd)
> This happens very infrequently, the OS is Windows 7 and the filesystem
> is NTFS, if that helps...
It should help indeed:
http://blogs.msdn.com/b/oldnewthing/archive/2012/09/07/10347136.aspx
:-)
Regards
Antoine.
More information about the Python-Dev
mailing list