Skip to content

Commit 9ca70f4

Browse files
authored
Merge pull request #1509 from poldrack/master
added logic to prevent directory creation collisions
2 parents fbaca01 + 4fa1c2b commit 9ca70f4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

nipype/pipeline/engine/utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,15 @@ def make_output_dir(outdir):
10561056
outdir : output directory to create
10571057
10581058
"""
1059-
if not os.path.exists(os.path.abspath(outdir)):
1060-
logger.debug("Creating %s" % outdir)
1061-
os.makedirs(outdir)
1059+
# this odd approach deals with concurrent directory cureation
1060+
try:
1061+
if not os.path.exists(os.path.abspath(outdir)):
1062+
logger.debug("Creating %s" % outdir)
1063+
os.makedirs(outdir)
1064+
except OSError:
1065+
logger.debug("Problem creating %s" % outdir)
1066+
if not os.path.exists(outdir):
1067+
raise OSError('Could not create %s'%outdir)
10621068
return outdir
10631069

10641070

0 commit comments

Comments
 (0)