Commit 861f539e authored by Sam Thursfield's avatar Sam Thursfield

functional-tests: Fix race condition when creating temporary directory

This code path would fail if two tests tried to create the
directory at the same time. We should ignore EEXIST rather than doing
a check + create sequence that isn't atomic.
parent 098e2f2a
Pipeline #65608 passed with stage
in 1 minute and 4 seconds
......@@ -111,8 +111,13 @@ if _TEST_MONITORED_TMP_DIR.startswith('/tmp'):
def create_monitored_test_dir():
'''Returns a unique tmpdir which supports filesystem monitor events.'''
if not os.path.exists(_TEST_MONITORED_TMP_DIR):
try:
os.makedirs(_TEST_MONITORED_TMP_DIR)
except OSError as e:
if e.errno == errno.EEXIST:
pass
else:
raise
return tempfile.mkdtemp(dir=_TEST_MONITORED_TMP_DIR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment