本文整理汇总了Python中test.test_support.reap_children函数的典型用法代码示例。如果您正苦于以下问题:Python reap_children函数的具体用法?Python reap_children怎么用?Python reap_children使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reap_children函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test():
import sys
if sys.platform[:3] in ('win', 'mac', 'os2', 'riscos'):
if verbose:
print "Can't test select easily on", sys.platform
return
cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 0.1; done'
p = os.popen(cmd, 'r')
for tout in (0, 0.1, 0.2, 0.4, 0.8, 1.6) + (None,)*10:
if verbose:
print 'timeout =', tout
rfd, wfd, xfd = select.select([p], [], [], tout)
if (rfd, wfd, xfd) == ([], [], []):
continue
if (rfd, wfd, xfd) == ([p], [], []):
line = p.readline()
if verbose:
print repr(line)
if not line:
if verbose:
print 'EOF'
break
continue
print 'Unexpected return values from select():', rfd, wfd, xfd
p.close()
reap_children()
示例2: test
def test():
import sys
if sys.platform[:3] in ("win", "mac", "os2", "riscos"):
if verbose:
print "Can't test select easily on", sys.platform
return
cmd = "for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done"
p = os.popen(cmd, "r")
for tout in (0, 1, 2, 4, 8, 16) + (None,) * 10:
if verbose:
print "timeout =", tout
rfd, wfd, xfd = select.select([p], [], [], tout)
if (rfd, wfd, xfd) == ([], [], []):
continue
if (rfd, wfd, xfd) == ([p], [], []):
line = p.readline()
if verbose:
print repr(line)
if not line:
if verbose:
print "EOF"
break
continue
print "Unexpected return values from select():", rfd, wfd, xfd
p.close()
reap_children()
示例3: test_main
def test_main():
try:
test.test_support.run_unittest(PyDocDocTest,
PydocImportTest,
TestDescriptions,
TestHelper)
finally:
reap_children()
示例4: test_main
def test_main():
test_support.run_unittest(
BZ2FileTest,
BZ2CompressorTest,
BZ2DecompressorTest,
FuncTest
)
test_support.reap_children()
示例5: test_main
def test_main():
unit_tests = (ProcessTestCase,
POSIXProcessTestCase,
Win32ProcessTestCase,
ProcessTestCaseNoPoll,
HelperFunctionTests)
test_support.run_unittest(*unit_tests)
test_support.reap_children()
示例6: tearDown
def tearDown (self):
signal_alarm(0) # Didn't deadlock.
reap_children()
for fn in self.test_files:
try:
os.remove(fn)
except os.error:
pass
self.test_files[:] = []
示例7: test_main
def test_main():
try:
start_dir = os.path.dirname(__file__)
top_dir = os.path.dirname(os.path.dirname(start_dir))
test_loader = unittest.TestLoader()
# XXX find out how to use unittest.main, to get command-line options
# (failfast, catch, etc.)
run_unittest(test_loader.discover(start_dir, top_level_dir=top_dir))
finally:
reap_children()
示例8: test_main
def test_main():
import imp
if imp.lock_held():
# If the import lock is held, the threads will hang.
raise TestSkipped("can't run when import lock is held")
try:
testall()
finally:
cleanup()
reap_children()
示例9: run_pydoc
def run_pydoc(module_name, *args):
"""
Runs pydoc on the specified module. Returns the stripped
output of pydoc.
"""
cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name]
try:
output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
return output.strip()
finally:
reap_children()
示例10: tearDown
def tearDown(self):
for inst in popen2._active:
inst.wait()
popen2._cleanup()
self.assertFalse(popen2._active, "popen2._active not empty")
# The os.popen*() API delegates to the subprocess module (on Unix)
import subprocess
for inst in subprocess._active:
inst.wait()
subprocess._cleanup()
self.assertFalse(subprocess._active, "subprocess._active not empty")
reap_children()
示例11: test_main
def test_main(verbose=None):
cwd = os.getcwd()
env = os.environ.copy()
try:
test_support.run_unittest(BaseHTTPServerTestCase,
SimpleHTTPServerTestCase,
CGIHTTPServerTestCase
)
finally:
test_support.reap_children()
os.environ.clear()
os.environ.update(env)
os.chdir(cwd)
示例12: test_main
def test_main():
try:
test_support.run_unittest(ProcessPoolExecutorTest,
ThreadPoolExecutorTest,
ProcessPoolWaitTests,
ThreadPoolWaitTests,
ProcessPoolAsCompletedTests,
ThreadPoolAsCompletedTests,
FutureTests,
ProcessPoolShutdownTest,
ThreadPoolShutdownTest)
finally:
test_support.reap_children()
示例13: tearDown
def tearDown(self):
for inst in popen2._active:
inst.wait()
popen2._cleanup()
self.assertFalse(popen2._active, "popen2._active not empty")
# The os.popen*() API delegates to the subprocess module (on Unix)
if not due_to_ironpython_bug("http://ironpython.codeplex.com/workitem/15512"):
import subprocess
for inst in subprocess._active:
inst.wait()
subprocess._cleanup()
self.assertFalse(subprocess._active, "subprocess._active not empty")
reap_children()
示例14: test_popen
def test_popen(self):
self.assertRaises(TypeError, os.popen)
self._do_test_commandline(
"foo bar",
["foo", "bar"]
)
self._do_test_commandline(
'foo "spam and eggs" "silly walk"',
["foo", "spam and eggs", "silly walk"]
)
self._do_test_commandline(
'foo "a \\"quoted\\" arg" bar',
["foo", 'a "quoted" arg', "bar"]
)
test_support.reap_children()
示例15: sloppy_cleanup
def sloppy_cleanup():
# See http://python.org/sf/1540386
# We need to reap children here otherwise a child from one server
# can be left running for the next server and cause a test failure.
time.sleep(DELAY)
reap_children()