yang: fix race condition in embedmodel.py mkdir

Parallel build may be executing another copy of embedmodel.py at the
same time, with both getting "False" on the isdir check, and then both
trying to mkdir - one of which will error out.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2023-01-24 18:17:05 +01:00
parent d173381edc
commit 05a13c2cd4
1 changed files with 3 additions and 1 deletions

View File

@ -12,8 +12,10 @@ inname = sys.argv[1]
outname = sys.argv[2]
outdir = os.path.dirname(os.path.abspath(outname))
if not os.path.isdir(outdir):
try:
os.makedirs(outdir)
except FileExistsError:
pass
# these are regexes to avoid a compile-time/host dependency on yang-tools
# or python-yang. Cross-compiling FRR is already somewhat involved, no need