fix race condition creating folder

This commit is contained in:
Dirk Thomas 2016-11-25 01:19:07 -08:00
parent 6d313131cd
commit 20697c547d
1 changed files with 6 additions and 1 deletions

View File

@ -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)