summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Crosta <dcrosta@10gen.com>2012-03-01 17:36:58 -0500
committerDan Crosta <dcrosta@10gen.com>2012-03-01 17:36:58 -0500
commitc5463305226dfb8f42eb5235ac381442006b29dd (patch)
tree9b8817243f7f35cc46f6c8b8c9803de14c5a80e6
parent05da017dee6c2ca146eeed8c4d14fbbf2c2b6330 (diff)
downloadmongo-c5463305226dfb8f42eb5235ac381442006b29dd.tar.gz
SERVER-5140: avoid a bug in SCons with subprocess.Popen
SCons overrides the subprocess module with its own custom implementation (forked from an earlier version of Python, but with some patches). SCons' implementation acquires a lock but does not release it during Popen() if the command being executed cannot be found. The next invocation of Popen() will hang indefinitely attempting to acquire the lock. Moving smoke_python_name() to a python module (i.e. out of the SCons-managed files) causes "import subprocess" to find the actual, system-installed subprocess module, which does not contain the buggy locking.
-rw-r--r--SConstruct27
-rw-r--r--buildscripts/utils.py23
2 files changed, 25 insertions, 25 deletions
diff --git a/SConstruct b/SConstruct
index dbe95a36b4a..e536f8a03ca 100644
--- a/SConstruct
+++ b/SConstruct
@@ -817,29 +817,6 @@ def add_exe(target):
return target + ".exe"
return target
-def smoke_python_name():
- # if this script is being run by py2.5 or greater,
- # then we assume that "python" points to a 2.5 or
- # greater python VM. otherwise, explicitly use 2.5
- # which we assume to be installed.
- import subprocess
- version = re.compile(r'[Pp]ython ([\d\.]+)', re.MULTILINE)
- binaries = ['python2.5', 'python2.6', 'python2.7', 'python25', 'python26', 'python27', 'python']
- for binary in binaries:
- try:
- # py-2.4 compatible replacement for shell backticks
- out, err = subprocess.Popen([binary, '-V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- for stream in (out, err):
- match = version.search(stream)
- if match:
- versiontuple = tuple(map(int, match.group(1).split('.')))
- if versiontuple >= (2, 5):
- return binary
- except:
- pass
- # if that all fails, fall back to "python"
- return "python"
-
def setupBuildInfoFile( outFile ):
version = utils.getGitVersion()
if len(moduleNames) > 0:
@@ -1253,7 +1230,7 @@ def addSmoketest( name, deps ):
else:
target = name[5].lower() + name[6:]
- addTest(name, deps, [ smoke_python_name() + " buildscripts/smoke.py " + " ".join(smokeFlags) + ' ' + target ])
+ addTest(name, deps, [ utils.smoke_python_name() + " buildscripts/smoke.py " + " ".join(smokeFlags) + ' ' + target ])
addSmoketest( "smoke", [ add_exe( "test" ) ] )
addSmoketest( "smokePerf", [ "perftest" ] )
@@ -1651,7 +1628,7 @@ def build_and_test_client(env, target, source):
call(scons_command + ["libmongoclient.a", "clientTests"], cwd=installDir)
- return bool(call([smoke_python_name(), "buildscripts/smoke.py",
+ return bool(call([utils.smoke_python_name(), "buildscripts/smoke.py",
"--test-path", installDir, "client"]))
env.Alias("clientBuild", [mongod, installDir], [build_and_test_client])
env.AlwaysBuild("clientBuild")
diff --git a/buildscripts/utils.py b/buildscripts/utils.py
index 8021d8779da..91409c7db70 100644
--- a/buildscripts/utils.py
+++ b/buildscripts/utils.py
@@ -134,3 +134,26 @@ def didMongodStart( port=27017 , timeout=20 ):
timeout = timeout - 1
return False
+def smoke_python_name():
+ # if this script is being run by py2.5 or greater,
+ # then we assume that "python" points to a 2.5 or
+ # greater python VM. otherwise, explicitly use 2.5
+ # which we assume to be installed.
+ import subprocess
+ version = re.compile(r'[Pp]ython ([\d\.]+)', re.MULTILINE)
+ binaries = ['python2.5', 'python2.6', 'python2.7', 'python25', 'python26', 'python27', 'python']
+ for binary in binaries:
+ try:
+ # py-2.4 compatible replacement for shell backticks
+ out, err = subprocess.Popen([binary, '-V'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
+ for stream in (out, err):
+ match = version.search(stream)
+ if match:
+ versiontuple = tuple(map(int, match.group(1).split('.')))
+ if versiontuple >= (2, 5):
+ return binary
+ except:
+ pass
+ # if that all fails, fall back to "python"
+ return "python"
+