[Python-checkins] r47158 - in python/trunk: Lib/test/test_bz2.py Lib/test/test_cmd_line.py Lib/test/test_commands.py Lib/test/test_fork1.py Lib/test/test_mailbox.py Lib/test/test_popen.py Lib/test/test_popen2.py Lib/test/test_select.py Lib/test/test_socketserver.py Lib/test/test_subprocess.py Lib/test/test_support.py Lib/test/test_wait3.py Lib/test/test_wait4.py Misc/NEWS
neal.norwitz
python-checkins at python.org
Thu Jun 29 06:10:11 CEST 2006
Author: neal.norwitz
Date: Thu Jun 29 06:10:08 2006
New Revision: 47158
Modified:
python/trunk/Lib/test/test_bz2.py
python/trunk/Lib/test/test_cmd_line.py
python/trunk/Lib/test/test_commands.py
python/trunk/Lib/test/test_fork1.py
python/trunk/Lib/test/test_mailbox.py
python/trunk/Lib/test/test_popen.py
python/trunk/Lib/test/test_popen2.py
python/trunk/Lib/test/test_select.py
python/trunk/Lib/test/test_socketserver.py
python/trunk/Lib/test/test_subprocess.py
python/trunk/Lib/test/test_support.py
python/trunk/Lib/test/test_wait3.py
python/trunk/Lib/test/test_wait4.py
python/trunk/Misc/NEWS
Log:
Add new utility function, reap_children(), to test_support. This should
be called at the end of each test that spawns children (perhaps it
should be called from regrtest instead?). This will hopefully prevent
some of the unexplained failures in the buildbots (hppa and alpha)
during tests that spawn children. The problems were not reproducible.
There were many zombies that remained at the end of several tests.
In the worst case, this shouldn't cause any more problems,
though it may not help either. Time will tell.
Modified: python/trunk/Lib/test/test_bz2.py
==============================================================================
--- python/trunk/Lib/test/test_bz2.py (original)
+++ python/trunk/Lib/test/test_bz2.py Thu Jun 29 06:10:08 2006
@@ -352,6 +352,7 @@
BZ2DecompressorTest,
FuncTest
)
+ test_support.reap_children()
if __name__ == '__main__':
test_main()
Modified: python/trunk/Lib/test/test_cmd_line.py
==============================================================================
--- python/trunk/Lib/test/test_cmd_line.py (original)
+++ python/trunk/Lib/test/test_cmd_line.py Thu Jun 29 06:10:08 2006
@@ -87,6 +87,7 @@
def test_main():
test.test_support.run_unittest(CmdLineTest)
+ test.test_support.reap_children()
if __name__ == "__main__":
test_main()
Modified: python/trunk/Lib/test/test_commands.py
==============================================================================
--- python/trunk/Lib/test/test_commands.py (original)
+++ python/trunk/Lib/test/test_commands.py Thu Jun 29 06:10:08 2006
@@ -5,7 +5,7 @@
import unittest
import os, tempfile, re
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
from commands import *
# The module says:
@@ -58,6 +58,7 @@
def test_main():
run_unittest(CommandTests)
+ reap_children()
if __name__ == "__main__":
Modified: python/trunk/Lib/test/test_fork1.py
==============================================================================
--- python/trunk/Lib/test/test_fork1.py (original)
+++ python/trunk/Lib/test/test_fork1.py Thu Jun 29 06:10:08 2006
@@ -3,7 +3,7 @@
import os
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
try:
os.fork
@@ -18,6 +18,7 @@
def test_main():
run_unittest(ForkTest)
+ reap_children()
if __name__ == "__main__":
test_main()
Modified: python/trunk/Lib/test/test_mailbox.py
==============================================================================
--- python/trunk/Lib/test/test_mailbox.py (original)
+++ python/trunk/Lib/test/test_mailbox.py Thu Jun 29 06:10:08 2006
@@ -1785,6 +1785,7 @@
TestMessageConversion, TestProxyFile, TestPartialFile,
MaildirTestCase)
test_support.run_unittest(*tests)
+ test_support.reap_children()
if __name__ == '__main__':
Modified: python/trunk/Lib/test/test_popen.py
==============================================================================
--- python/trunk/Lib/test/test_popen.py (original)
+++ python/trunk/Lib/test/test_popen.py Thu Jun 29 06:10:08 2006
@@ -6,7 +6,7 @@
import os
import sys
-from test.test_support import TestSkipped
+from test.test_support import TestSkipped, reap_children
from os import popen
# Test that command-lines get down as we expect.
@@ -35,5 +35,6 @@
def main():
print "Test popen:"
_test_commandline()
+ reap_children()
main()
Modified: python/trunk/Lib/test/test_popen2.py
==============================================================================
--- python/trunk/Lib/test/test_popen2.py (original)
+++ python/trunk/Lib/test/test_popen2.py Thu Jun 29 06:10:08 2006
@@ -5,7 +5,7 @@
import os
import sys
-from test.test_support import TestSkipped
+from test.test_support import TestSkipped, reap_children
# popen2 contains its own testing routine
# which is especially useful to see if open files
@@ -75,3 +75,4 @@
main()
_test()
+reap_children()
Modified: python/trunk/Lib/test/test_select.py
==============================================================================
--- python/trunk/Lib/test/test_select.py (original)
+++ python/trunk/Lib/test/test_select.py Thu Jun 29 06:10:08 2006
@@ -1,5 +1,5 @@
# Testing select module
-from test.test_support import verbose
+from test.test_support import verbose, reap_children
import select
import os
@@ -65,5 +65,6 @@
continue
print 'Unexpected return values from select():', rfd, wfd, xfd
p.close()
+ reap_children()
test()
Modified: python/trunk/Lib/test/test_socketserver.py
==============================================================================
--- python/trunk/Lib/test/test_socketserver.py (original)
+++ python/trunk/Lib/test/test_socketserver.py Thu Jun 29 06:10:08 2006
@@ -1,7 +1,8 @@
# Test suite for SocketServer.py
from test import test_support
-from test.test_support import verbose, verify, TESTFN, TestSkipped
+from test.test_support import (verbose, verify, TESTFN, TestSkipped,
+ reap_children)
test_support.requires('network')
from SocketServer import *
@@ -199,6 +200,7 @@
testall()
finally:
cleanup()
+ reap_children()
if __name__ == "__main__":
test_main()
Modified: python/trunk/Lib/test/test_subprocess.py
==============================================================================
--- python/trunk/Lib/test/test_subprocess.py (original)
+++ python/trunk/Lib/test/test_subprocess.py Thu Jun 29 06:10:08 2006
@@ -27,6 +27,16 @@
return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
class ProcessTestCase(unittest.TestCase):
+ def setUp(self):
+ # Try to minimize the number of children we have so this test
+ # doesn't crash on some buildbots (Alphas in particular).
+ test_support.reap_children()
+
+ def tearDown(self):
+ # Try to minimize the number of children we have so this test
+ # doesn't crash on some buildbots (Alphas in particular).
+ test_support.reap_children()
+
def mkstemp(self):
"""wrapper for mkstemp, calling mktemp if mkstemp is not available"""
if hasattr(tempfile, "mkstemp"):
@@ -600,6 +610,7 @@
def test_main():
test_support.run_unittest(ProcessTestCase)
+ test_support.reap_children()
if __name__ == "__main__":
test_main()
Modified: python/trunk/Lib/test/test_support.py
==============================================================================
--- python/trunk/Lib/test/test_support.py (original)
+++ python/trunk/Lib/test/test_support.py Thu Jun 29 06:10:08 2006
@@ -475,3 +475,24 @@
while len(threading._limbo) != num_limbo and count < _MAX_COUNT:
count += 1
time.sleep(0.1)
+
+def reap_children():
+ """Use this function at the end of test_main() whenever sub-processes
+ are started. This will help ensure that no extra children (zombies)
+ stick around to hog resources and create problems when looking
+ for refleaks.
+ """
+
+ # Reap all our dead child processes so we don't leave zombies around.
+ # These hog resources and might be causing some of the buildbots to die.
+ import os
+ if hasattr(os, 'waitpid'):
+ any_process = -1
+ while True:
+ try:
+ # This will raise an exception on Windows. That's ok.
+ pid, status = os.waitpid(any_process, os.WNOHANG)
+ if pid == 0:
+ break
+ except:
+ break
Modified: python/trunk/Lib/test/test_wait3.py
==============================================================================
--- python/trunk/Lib/test/test_wait3.py (original)
+++ python/trunk/Lib/test/test_wait3.py Thu Jun 29 06:10:08 2006
@@ -3,7 +3,7 @@
import os
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
try:
os.fork
@@ -27,6 +27,7 @@
def test_main():
run_unittest(Wait3Test)
+ reap_children()
if __name__ == "__main__":
test_main()
Modified: python/trunk/Lib/test/test_wait4.py
==============================================================================
--- python/trunk/Lib/test/test_wait4.py (original)
+++ python/trunk/Lib/test/test_wait4.py Thu Jun 29 06:10:08 2006
@@ -3,7 +3,7 @@
import os
from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
try:
os.fork
@@ -24,6 +24,7 @@
def test_main():
run_unittest(Wait4Test)
+ reap_children()
if __name__ == "__main__":
test_main()
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu Jun 29 06:10:08 2006
@@ -48,6 +48,12 @@
- Bug #1513032: 'make install' failed on FreeBSD 5.3 due to lib-old
trying to be installed even though it's empty.
+Tests
+-----
+
+- Call os.waitpid() at the end of tests that spawn child processes in order
+ to minimize resources (zombies).
+
What's New in Python 2.5 beta 1?
================================
More information about the Python-checkins
mailing list