本文整理汇总了Python中psutil.tests.reap_children函数的典型用法代码示例。如果您正苦于以下问题:Python reap_children函数的具体用法?Python reap_children怎么用?Python reap_children使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reap_children函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reap_children
def test_reap_children(self):
subp = get_test_subprocess()
p = psutil.Process(subp.pid)
assert p.is_running()
reap_children()
assert not p.is_running()
assert not psutil.tests._pids_started
assert not psutil.tests._subprocesses_started
示例2: tearDown
def tearDown(self):
safe_rmpath(TESTFN)
reap_children()
if not NETBSD:
# Make sure we closed all resources.
# NetBSD opens a UNIX socket to /var/log/run.
cons = thisproc.connections(kind='all')
assert not cons, cons
示例3: subprocess_supports_unicode
def subprocess_supports_unicode(name):
"""Return True if both the fs and the subprocess module can
deal with a unicode file name.
"""
if PY3:
return True
try:
safe_rmpath(name)
create_exe(name)
get_test_subprocess(cmd=[name])
except UnicodeEncodeError:
return False
else:
reap_children()
return True
示例4: test_pid_exists_2
def test_pid_exists_2(self):
reap_children()
pids = psutil.pids()
for pid in pids:
try:
assert psutil.pid_exists(pid)
except AssertionError:
# in case the process disappeared in meantime fail only
# if it is no longer in psutil.pids()
time.sleep(.1)
if pid in psutil.pids():
self.fail(pid)
pids = range(max(pids) + 5000, max(pids) + 6000)
for pid in pids:
self.assertFalse(psutil.pid_exists(pid), msg=pid)
示例5: test_create_proc_children_pair
def test_create_proc_children_pair(self):
p1, p2 = create_proc_children_pair()
self.assertNotEqual(p1.pid, p2.pid)
assert p1.is_running()
assert p2.is_running()
children = psutil.Process().children(recursive=True)
self.assertEqual(len(children), 2)
self.assertIn(p1, children)
self.assertIn(p2, children)
self.assertEqual(p1.ppid(), os.getpid())
self.assertEqual(p2.ppid(), p1.pid)
# make sure both of them are cleaned up
reap_children()
assert not p1.is_running()
assert not p2.is_running()
assert not psutil.tests._pids_started
assert not psutil.tests._subprocesses_started
示例6: tearDownClass
def tearDownClass(cls):
reap_children()
示例7: tearDown
def tearDown(self):
reap_children()
safe_rmpath(self.funky_name)
示例8: tearDown
def tearDown(self):
reap_children()
示例9: tearDownClass
def tearDownClass(cls):
super(TestTerminatedProcessLeaks, cls).tearDownClass()
reap_children()
示例10: tearDown
def tearDown(self):
self.proc32.communicate()
self.proc64.communicate()
reap_children()
示例11: tearDownClass
def tearDownClass(cls):
reap_children()
safe_rmpath(cls.funky_name)
示例12: test_reap_children
def test_reap_children(self):
subp = get_test_subprocess()
assert psutil.pid_exists(subp.pid)
reap_children()
assert not psutil.pid_exists(subp.pid)