From 20697c547db5afcd547c1d57ddf42069670611a3 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 25 Nov 2016 01:19:07 -0800 Subject: [PATCH] fix race condition creating folder --- tools/rosunit/src/rosunit/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/rosunit/src/rosunit/core.py b/tools/rosunit/src/rosunit/core.py index 38726b91..4b349ba2 100644 --- a/tools/rosunit/src/rosunit/core.py +++ b/tools/rosunit/src/rosunit/core.py @@ -32,6 +32,7 @@ from __future__ import print_function +import errno import os import sys import logging @@ -74,7 +75,11 @@ def makedirs_with_parent_perms(p): if not os.path.exists(p) and p and parent != p: makedirs_with_parent_perms(parent) s = os.stat(parent) - os.mkdir(p) + try: + os.mkdir(p) + except OSError as e: + if e.errno != errno.EEXIST: + raise # if perms of new dir don't match, set anew s2 = os.stat(p)