From 06687fabf0e4a0f068a685383fd713fd09ce7875 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 2 May 2020 18:43:39 +0200 Subject: don't use Pool ctx manager (py 2.7 compat) --- psutil/tests/test_contracts.py | 16 +++++++++++----- 1 file 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 : 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) -- cgit v1.2.1