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.

Change-Id: I6b6682e3af34f43da4e397d602e9ee4e1c83970f
Related-Bug: 1645918
This commit is contained in:
Dirk Mueller 2017-01-18 20:18:47 +01:00
parent e403a6bad0
commit e1e0ef0916
1 changed files with 6 additions and 1 deletions

View File

@ -60,7 +60,12 @@ PHASES = ['pre-configure',
def timeout():
p = psutil.Process()
children = list(p.get_children(recursive=True))
try:
# psutils version >= 2
children = list(p.children(recursive=True))
except AttributeError:
children = list(p.get_children(recursive=True))
for child in children:
child.kill()