mirror of https://github.com/pytest-dev/pytest.git
Merge pull request #10638 from pytest-dev/backport-10607-to-7.2.x
[7.2.x] Mitigate directory creation race condition
This commit is contained in:
commit
211d08e9bc
|
@ -0,0 +1 @@
|
|||
Fix a race condition when creating junitxml reports, which could occur when multiple instances of pytest execute in parallel.
|
|
@ -645,8 +645,8 @@ class LogXML:
|
|||
|
||||
def pytest_sessionfinish(self) -> None:
|
||||
dirname = os.path.dirname(os.path.abspath(self.logfile))
|
||||
if not os.path.isdir(dirname):
|
||||
os.makedirs(dirname)
|
||||
# exist_ok avoids filesystem race conditions between checking path existence and requesting creation
|
||||
os.makedirs(dirname, exist_ok=True)
|
||||
|
||||
with open(self.logfile, "w", encoding="utf-8") as logfile:
|
||||
suite_stop_time = timing.time()
|
||||
|
|
Loading…
Reference in New Issue