Adjust test suite for new psutil versions
psutil 2.x and above has a lot of API changes as described in: https://github.com/giampaolo/psutil/blob/master/HISTORY.rst So we should work correctly with both old and new psutil versions by using a version check and use the correct method/attributes. This allows to eventually unlift the version cap that starts to hurt. Related-Bug: 1645918 Change-Id: I6be775e83876271012f6b7a777ea2b5cc3a008f6
This commit is contained in:
parent
03567be314
commit
06c4313ec0
|
@ -76,7 +76,12 @@ class TestReload(functional.FunctionalTest):
|
|||
pid = None
|
||||
pid = self._get_parent(server)
|
||||
process = psutil.Process(pid)
|
||||
children = process.get_children()
|
||||
try:
|
||||
# psutils version >= 2
|
||||
children = process.children()
|
||||
except AttributeError:
|
||||
# psutils version < 2
|
||||
children = process.get_children()
|
||||
pids = set()
|
||||
for child in children:
|
||||
pids.add(child.pid)
|
||||
|
|
|
@ -47,8 +47,12 @@ class TestMultiprocessing(functional.FunctionalTest):
|
|||
def _get_children(self):
|
||||
api_pid = self.api_server.process_pid
|
||||
process = psutil.Process(api_pid)
|
||||
|
||||
children = process.get_children()
|
||||
try:
|
||||
# psutils version >= 2
|
||||
children = process.children()
|
||||
except AttributeError:
|
||||
# psutils version < 2
|
||||
children = process.get_children()
|
||||
pids = [str(child.pid) for child in children]
|
||||
return pids
|
||||
|
||||
|
|
Loading…
Reference in New Issue