0

fixed race condition in creating directories

This commit is contained in:
Andrew Brown
2010-09-18 10:53:50 -04:00
parent 7e62ab355f
commit b12e2d1c8c

View File

@@ -432,7 +432,15 @@ def render_worldtile(chunks, colstart, colend, rowstart, rowend, path):
# Create the directory if not exists
dirdest = os.path.dirname(path)
if not os.path.exists(dirdest):
os.makedirs(dirdest)
try:
os.makedirs(dirdest)
except OSError, e:
# Ignore errno EEXIST: file exists. Since this is multithreaded,
# two processes could conceivably try and create the same directory
# at the same time.
import errno
if e.errno != errno.EEXIST:
raise
imghash = hashlib.md5()
for col, row, chunkfile in chunks: