summaryrefslogtreecommitdiffstats
path: root/Lib/test/regrtest.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-04-16 16:53:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-04-16 16:53:59 (GMT)
commitee4293400cff1d5f9a7a6dd8e9aaa6ba6623e348 (patch)
tree579ae44f65b5632aeb744f56446f0dfadce0c1c3 /Lib/test/regrtest.py
parent1d827ff43d6340db759ddc08c6ab1efa3e1886d1 (diff)
downloadcpython-ee4293400cff1d5f9a7a6dd8e9aaa6ba6623e348.zip
cpython-ee4293400cff1d5f9a7a6dd8e9aaa6ba6623e348.tar.gz
cpython-ee4293400cff1d5f9a7a6dd8e9aaa6ba6623e348.tar.bz2
Fix possible "file already exists" error when running the tests in parallel.
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.
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-xLib/test/regrtest.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 89acb9b..e2e3765 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -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