Skip to content
Snippets Groups Projects
Unverified Commit 1328c096 authored by Luis González's avatar Luis González Committed by Martin Trigaux
Browse files

[IMP] tools: avoid concurrent creation of the session_dir

Instead of:
1. testing the existance
2. creating the directory if not exists

(which would not work if a concurrent creation is done between step 1 and 2)

do:
1. try to create the directory
2. skip if it fails

Ask forgiveness, not permission

Closes #24210
parent 7a24df48
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ try:
except ImportError:
import ConfigParser
import errno
import logging
import optparse
import os
......@@ -620,9 +621,11 @@ class configmanager(object):
@property
def session_dir(self):
d = os.path.join(self['data_dir'], 'sessions')
if not os.path.exists(d):
try:
os.makedirs(d, 0o700)
else:
except OSError as e:
if e.errno != errno.EEXIST:
raise
assert os.access(d, os.W_OK), \
"%s: directory is not writable" % d
return d
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment