Skip to content

Commit 94d39f6

Browse files
AMDmi3matthiaskrgr
authored andcommitted
Fix matchcompiler failure in case of parallel build
During parallel build, multiple processes will try to create build_dir in parallel, so the build will fail. Fix that by calling makedirs unconditionally and ignoring errors from it. If there's actual problem with directory creation, it'll be caught later by isdir() check.
1 parent d887458 commit 94d39f6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/matchcompiler.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import re
2323
import glob
2424
import argparse
25+
import errno
2526

2627

2728
class MatchCompiler:
@@ -667,8 +668,16 @@ def main():
667668
sys.exit(-1)
668669

669670
# Create build directory if needed
670-
if not os.path.exists(build_dir):
671+
try:
671672
os.makedirs(build_dir)
673+
except OSError as e:
674+
# due to race condition in case of parallel build,
675+
# makedirs may fail. Ignore that; if there's actual
676+
# problem with directory creation, it'll be caught
677+
# by the following isdir check
678+
if e.errno != errno.EEXIST:
679+
raise
680+
672681
if not os.path.isdir(build_dir):
673682
raise Exception(build_dir + ' is not a directory')
674683

0 commit comments

Comments
 (0)