generator_lib.py: Fix exception when racing for dir creation.
The generator_lib.py processing of file renders would check that the output directory doesn't exist and if needed, would create it. However by default makedirs errors if the path already exists. This caused issues when multiple generator_lib.py generators with the same output dir would run in parallel in builds, because there can be a race where: - GeneratorA: Check os.path.exists -> returns False - GeneratorB: Check os.path.exists -> returns False - GeneratorB: os.makedirs -> Ok - GeneratorA: os.makedirs -> Exception, fails the build. Instead use os.makedirs(exist_ok=True) inconditionally to remove this racy behavior. Bug: None Change-Id: I5cb401a1df11a3640faeea94c15cb54236edc05a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114521 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
ad541a7cdd
commit
20a6ca0041
|
@ -335,8 +335,7 @@ def run_generator(generator):
|
||||||
output_path = os.path.join(args.output_dir, output.name)
|
output_path = os.path.join(args.output_dir, output.name)
|
||||||
|
|
||||||
directory = os.path.dirname(output_path)
|
directory = os.path.dirname(output_path)
|
||||||
if not os.path.exists(directory):
|
os.makedirs(directory, exist_ok=True)
|
||||||
os.makedirs(directory)
|
|
||||||
|
|
||||||
with open(output_path, 'w') as outfile:
|
with open(output_path, 'w') as outfile:
|
||||||
outfile.write(output.content)
|
outfile.write(output.content)
|
||||||
|
|
Loading…
Reference in New Issue