summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-05-02 18:43:39 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2020-05-02 18:43:39 +0200
commit06687fabf0e4a0f068a685383fd713fd09ce7875 (patch)
tree37323f53e62f6b85f79bd359df0c26f6bd8f714e
parent3190b4085e8b836f78d346bd07d6710d1f663262 (diff)
downloadpsutil-test-fetch-all-parallel.tar.gz
don't use Pool ctx manager (py 2.7 compat)test-fetch-all-parallel
-rwxr-xr-xpsutil/tests/test_contracts.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py
index c0889843..d20c9c6b 100755
--- a/psutil/tests/test_contracts.py
+++ b/psutil/tests/test_contracts.py
@@ -352,16 +352,22 @@ class TestFetchAllProcesses(PsutilTestCase):
Uses a process pool to get info about all processes.
"""
+ def setUp(self):
+ self.pool = multiprocessing.Pool()
+
+ def tearDown(self):
+ self.pool.terminate()
+ self.pool.join()
+
def test_all(self):
# Fixes "can't pickle <function proc_info>: it's not the
# same object as test_contracts.proc_info".
from psutil.tests.test_contracts import proc_info
- with multiprocessing.Pool() as pool:
- for info in pool.imap_unordered(proc_info, psutil.pids()):
- for name, value in info.items():
- meth = getattr(self, name)
- meth(value, info)
+ for info in self.pool.imap_unordered(proc_info, psutil.pids()):
+ for name, value in info.items():
+ meth = getattr(self, name)
+ meth(value, info)
def cmdline(self, ret, info):
self.assertIsInstance(ret, list)