From 9c9b7675abff535bb1b80bd8e5c340ba5f0a7dbb Mon Sep 17 00:00:00 2001 From: Santosh Gupta Date: Mon, 27 Mar 2017 11:03:17 -0700 Subject: [PATCH] Add check for psutil process.get_cpu_times() Added a check for the psutil process.get_cpu_times() attribute before using it. Change-Id: I758624beac4e9192a855e1cec62f247f6bad9f88 Closes-Bug: #1671898 --- src/nodemgr/common/cpuinfo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nodemgr/common/cpuinfo.py b/src/nodemgr/common/cpuinfo.py index 9c671aef1a2..48824d09906 100644 --- a/src/nodemgr/common/cpuinfo.py +++ b/src/nodemgr/common/cpuinfo.py @@ -112,7 +112,10 @@ def _get_process_cpu_share(self): last_cpu = self.last_cpu last_time = self.last_time - current_cpu = self._process.get_cpu_times() + if hasattr(self._process, 'get_cpu_times'): + current_cpu = self._process.get_cpu_times() + else: + current_cpu = self._process.cpu_times() current_time = os.times()[4] # tracking system/user time only