run-tests: replace popen locking with a noop _cleanup handler on py24 stable
authorBrendan Cully <brendan@kublai.com>
Wed, 17 Jul 2013 13:42:08 -0700
branchstable
changeset 1283 e1d949ad7cda
parent 1282 f0c81b6d67c6
child 1284 3f370565e291
run-tests: replace popen locking with a noop _cleanup handler on py24 This also avoids the race condition, and isn't detrimental to job scheduling. [ original upstream message ]
tests/run-tests.py
--- a/tests/run-tests.py	Wed Jul 17 13:02:12 2013 -0700
+++ b/tests/run-tests.py	Wed Jul 17 13:42:08 2013 -0700
@@ -59,15 +59,12 @@
 import Queue as queue
 
 processlock = threading.Lock()
-waitlock = threading.Lock()
 
-def waitlocked(fn):
-    def run():
-        waitlock.acquire()
-        ret = fn()
-        waitlock.release()
-        return ret
-    return run
+# subprocess._cleanup can race with any Popen.wait or Popen.poll on py24
+# http://bugs.python.org/issue1731717 for details. We shouldn't be producing
+# zombies but it's pretty harmless even if we do.
+if sys.version_info[1] < 5:
+    subprocess._cleanup = lambda: None
 
 closefds = os.name == 'posix'
 def Popen4(cmd, wd, timeout, env=None):
@@ -76,9 +73,6 @@
                          close_fds=closefds,
                          stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                          stderr=subprocess.STDOUT)
-    if sys.version_info[1] < 5:
-        p.wait = waitlocked(p.wait)
-        p.poll = waitlocked(p.poll)
     processlock.release()
 
     p.fromchild = p.stdout