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.
This commit is contained in:
Dmitry Marakasov 2017-05-19 21:36:54 +03:00 committed by Matthias Krüger
parent d88745805f
commit 94d39f6e91
1 changed files with 10 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import sys
import re import re
import glob import glob
import argparse import argparse
import errno
class MatchCompiler: class MatchCompiler:
@ -667,8 +668,16 @@ def main():
sys.exit(-1) sys.exit(-1)
# Create build directory if needed # Create build directory if needed
if not os.path.exists(build_dir): try:
os.makedirs(build_dir) os.makedirs(build_dir)
except OSError as e:
# due to race condition in case of parallel build,
# makedirs may fail. Ignore that; if there's actual
# problem with directory creation, it'll be caught
# by the following isdir check
if e.errno != errno.EEXIST:
raise
if not os.path.isdir(build_dir): if not os.path.isdir(build_dir):
raise Exception(build_dir + ' is not a directory') raise Exception(build_dir + ' is not a directory')