[llvm] r257616 - [lit] Fix handling of per test timeout when the installed psutil version

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 08:43:49 PST 2016


Author: delcypher
Date: Wed Jan 13 10:43:49 2016
New Revision: 257616

URL: http://llvm.org/viewvc/llvm-project?rev=257616&view=rev
Log:
[lit] Fix handling of per test timeout when the installed psutil version
is < ``2.0``.

Older versions of psutil (e.g. ``1.2.1`` which is the version shipped with
Ubuntu 14.04) use a different API for retrieving the child processes.
To handle this try the new API first and if that fails try the old API.

Modified:
    llvm/trunk/utils/lit/lit/util.py

Modified: llvm/trunk/utils/lit/lit/util.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/util.py?rev=257616&r1=257615&r2=257616&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/util.py (original)
+++ llvm/trunk/utils/lit/lit/util.py Wed Jan 13 10:43:49 2016
@@ -267,7 +267,14 @@ def killProcessAndChildren(pid):
     import psutil
     try:
         psutilProc = psutil.Process(pid)
-        for child in psutilProc.children(recursive=True):
+        # Handle the different psutil API versions
+        try:
+            # psutil >= 2.x
+            children_iterator = psutilProc.children(recursive=True)
+        except AttributeError:
+            # psutil 1.x
+            children_iterator = psutilProc.get_children(recursive=True)
+        for child in children_iterator:
             try:
                 child.kill()
             except psutil.NoSuchProcess:




More information about the llvm-commits mailing list