[issue1675] Race condition in os.makedirs

Isaac Morland report at bugs.python.org
Thu Dec 20 20:59:57 CET 2007


Isaac Morland added the comment:

The only thing I found in the bug database concerning os.makedirs was
Issue 766910 (http://bugs.python.org/issue766910).  I realized
os.makedirs had a race condition because in my application I want to
create directories but it's perfectly fine if they already exist.  This
is exactly what trace.py in Issue 766910 seems to need.

I started writing my own, which was basically just os.makedirs but
calling my own version of os.mkdir which didn't worry about
already-existing directories, but realized that wouldn't work. 
Eventually I ended up with the routines I've put in the attached
makedirs.py.

I think os.makedirs can be fixed by making what is now its recursive
call instead call my version of makedirs.  I also think both my mkdir
and my makedirs should be present in the standard library as well as the
existing versions.  Possibly this could be done by adding a flag to the
existing versions, defaulted to obtain the current behaviour.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1675>
__________________________________


More information about the Python-bugs-list mailing list