diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-05-02 18:43:39 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-05-02 18:43:39 +0200 |
commit | 06687fabf0e4a0f068a685383fd713fd09ce7875 (patch) | |
tree | 37323f53e62f6b85f79bd359df0c26f6bd8f714e | |
parent | 3190b4085e8b836f78d346bd07d6710d1f663262 (diff) | |
download | psutil-test-fetch-all-parallel.tar.gz |
don't use Pool ctx manager (py 2.7 compat)test-fetch-all-parallel
-rwxr-xr-x | psutil/tests/test_contracts.py | 16 |
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) |