]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix possible "file already exists" error when running the tests in parallel.
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 16 Apr 2011 16:53:59 +0000 (18:53 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 16 Apr 2011 16:53:59 +0000 (18:53 +0200)
This is a perfect example of LBYL going wrong: that code could be executed
by several workers in parallel, and os.mkdir() attempted on the same
path by multiple processes.

Lib/test/regrtest.py
Misc/NEWS

index 89acb9b0a9dabd425942cb0266e96c0c4d694aec..e2e37652cc0be48354787fbeffaa7615c6c59afd 100755 (executable)
@@ -162,6 +162,7 @@ import re
 import io
 import sys
 import time
+import errno
 import traceback
 import warnings
 import unittest
@@ -1511,8 +1512,11 @@ def _make_temp_dir_for_build(TEMPDIR):
     if sysconfig.is_python_build():
         TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
         TEMPDIR = os.path.abspath(TEMPDIR)
-        if not os.path.exists(TEMPDIR):
+        try:
             os.mkdir(TEMPDIR)
+        except OSError as e:
+            if e.errno != errno.EEXIST:
+                raise
 
     # Define a writable temp dir that will be used as cwd while running
     # the tests. The name of the dir includes the pid to allow parallel
index 01b5119b0ddaf115395be7481bb017a0eb73be89..f5f08e431b08a1bdbe52285d7f7823251cb08c00 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -269,6 +269,8 @@ Extensions
 Tests
 -----
 
+- Fix possible "file already exists" error when running the tests in parallel.
+
 - Issue #11719: Fix message about unexpected test_msilib skip on non-Windows
   platforms. Patch by Nadeem Vawda.