BZ2DecompressorTest,
FuncTest
)
+ test_support.reap_children()
if __name__ == '__main__':
test_main()
def test_main():
test.test_support.run_unittest(CmdLineTest)
+ test.test_support.reap_children()
if __name__ == "__main__":
test_main()
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:
def test_main():
run_unittest(CommandTests)
+ reap_children()
if __name__ == "__main__":
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
def test_main():
run_unittest(ForkTest)
+ reap_children()
if __name__ == "__main__":
test_main()
TestMessageConversion, TestProxyFile, TestPartialFile,
MaildirTestCase)
test_support.run_unittest(*tests)
+ test_support.reap_children()
if __name__ == '__main__':
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.
def main():
print "Test popen:"
_test_commandline()
+ reap_children()
main()
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
main()
_test()
+reap_children()
# Testing select module
-from test.test_support import verbose
+from test.test_support import verbose, reap_children
import select
import os
continue
print 'Unexpected return values from select():', rfd, wfd, xfd
p.close()
+ reap_children()
test()
# 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 *
testall()
finally:
cleanup()
+ reap_children()
if __name__ == "__main__":
test_main()
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"):
def test_main():
test_support.run_unittest(ProcessTestCase)
+ test_support.reap_children()
if __name__ == "__main__":
test_main()
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
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
def test_main():
run_unittest(Wait3Test)
+ reap_children()
if __name__ == "__main__":
test_main()
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
def test_main():
run_unittest(Wait4Test)
+ reap_children()
if __name__ == "__main__":
test_main()
- 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?
================================