Skip to content

Commit

Permalink
fix: deadlock in psutil.tests.test_contracts.TestFetchAllProcesses.te…
Browse files Browse the repository at this point in the history
…st_all

Signed-off-by: mayeut <[email protected]>
  • Loading branch information
mayeut committed May 7, 2022
1 parent 4368824 commit ddc8969
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions psutil/tests/test_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,27 @@ class TestFetchAllProcesses(PsutilTestCase):
"""

def setUp(self):
self.pool = multiprocessing.Pool()
if LINUX and GITHUB_ACTIONS:
# the pool sometimes deadlocks on linux
# don't use it in CI
self.pool = None
else:
self.pool = multiprocessing.Pool()

def tearDown(self):
self.pool.terminate()
self.pool.join()
if self.pool is not None:
self.pool.terminate()
self.pool.join()

def iter_proc_info(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
return self.pool.imap_unordered(proc_info, psutil.pids())
if self.pool is None:
for pid in psutil.pids():
yield proc_info(pid)
else:
return self.pool.imap_unordered(proc_info, psutil.pids())

def test_all(self):
failures = []
Expand Down

0 comments on commit ddc8969

Please sign in to comment.