[build_id_conv] Use non-racy mkdir
Two instances of the script running at the same time were racy in their
mkdir behavior. Use os.makedirs and catch the EEXIST error rather than
using a racy precondition. In newer versions of Python, os.makedirs
takes an optional exists_ok=True parameter for this, but we can't rely
on having a Python that new.
Test: CQ
Change-Id: I48c096ab29b6a3159a784413df0413fa259670f3
diff --git a/build_id_conv.py b/build_id_conv.py
index 070a4ed..80b67f0 100755
--- a/build_id_conv.py
+++ b/build_id_conv.py
@@ -40,8 +40,11 @@
os.link(src, dst)
def mkdir(path):
- if not os.path.exists(path):
+ try:
os.makedirs(path)
+ except OSError as e:
+ if e.errno != os.errno.EEXIST:
+ raise e
def touch(path):
if os.path.exists(path):