Tolerate a config directory created concurrently by another process

Tool shed servers started by parallel pytest-xdist workers all create
the same compiled template directory; whichever lost the race failed to
start with 'File exists'.
This commit is contained in:
mvdbeek
2026-10-15 11:38:23 +02:00
parent c5f4e01b62
commit 6d200fb46e
+2 -1
View File
@@ -691,7 +691,8 @@ class CommonConfigurationMixin:
def _ensure_directory(self, path):
if path not in [None, False] and not os.path.isdir(path):
try:
os.makedirs(path)
# Another process starting with the same configuration may create it first.
os.makedirs(path, exist_ok=True)
except Exception as e:
raise ConfigurationError(f"Unable to create missing directory: {path}\n{unicodify(e)}")