This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Jeffrey.Kintscher
Recipients Jeffrey.Kintscher, giampaolo.rodola, tarek
Date 2019-06-13.01:10:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560388241.37.0.285109327745.issue37260@roundup.psfhosted.org>
In-reply-to
Content
shutil.rmtree() is susceptible to a race condition that can needlessly raise OSError:

1. os.scandir() returns the list of entries in a directory
2. while iterating over the list, another thread or process deletes one or more of the entries not yet iterated
3. os.unlink() or stat() raises OSError for the already deleted entry

It should check for and ignore, at a minimum, FileNotFoundError because we were going to delete the entry anyways.  For comparison, the 'rm -r' shell command handles this race condition by ignoring entries deleted from under it.

I will submit a PR when I work out some test cases to include.
History
Date User Action Args
2019-06-13 01:10:41Jeffrey.Kintschersetrecipients: + Jeffrey.Kintscher, giampaolo.rodola, tarek
2019-06-13 01:10:41Jeffrey.Kintschersetmessageid: <1560388241.37.0.285109327745.issue37260@roundup.psfhosted.org>
2019-06-13 01:10:41Jeffrey.Kintscherlinkissue37260 messages
2019-06-13 01:10:41Jeffrey.Kintschercreate