Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #554 from OP2/fix-compile-race
Browse files Browse the repository at this point in the history
* fix-compile-race:
  compilation: Fix race when creating output directories
  • Loading branch information
wence- committed Nov 9, 2018
2 parents 4d73bfc + b609345 commit df3f03a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyop2/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def compilation_comm(comm):
import tempfile
if comm.rank == 0:
if not os.path.exists(configuration["cache_dir"]):
os.makedirs(configuration["cache_dir"])
os.makedirs(configuration["cache_dir"], exist_ok=True)
tmpname = tempfile.mkdtemp(prefix="rank-determination-",
dir=configuration["cache_dir"])
else:
Expand Down Expand Up @@ -236,7 +236,7 @@ def get_so(self, src, extension):
srcfile = os.path.join(output, "src-rank%d.c" % self.comm.rank)
if self.comm.rank == 0:
if not os.path.exists(output):
os.makedirs(output)
os.makedirs(output, exist_ok=True)
self.comm.barrier()
with open(srcfile, "w") as f:
f.write(src)
Expand All @@ -250,7 +250,7 @@ def get_so(self, src, extension):
if self.comm.rank == 0:
# No need to do this on all ranks
if not os.path.exists(cachedir):
os.makedirs(cachedir)
os.makedirs(cachedir, exist_ok=True)
logfile = os.path.join(cachedir, "%s_p%d.log" % (basename, pid))
errfile = os.path.join(cachedir, "%s_p%d.err" % (basename, pid))
with progress(INFO, 'Compiling wrapper'):
Expand Down

0 comments on commit df3f03a

Please sign in to comment.