From d3160b8a332b47b43044e94c7bae2e3703203c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Wed, 6 Nov 2013 12:07:43 +0100 Subject: [PATCH] tuned: lowered CPU usage due to python bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: rhbz#917587 Signed-off-by: Jaroslav Škarvada --- tuned/daemon/controller.py | 2 +- tuned/daemon/daemon.py | 3 ++- tuned/utils/commands.py | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tuned/daemon/controller.py b/tuned/daemon/controller.py index 7cd5300..907e87c 100644 --- a/tuned/daemon/controller.py +++ b/tuned/daemon/controller.py @@ -28,7 +28,7 @@ class Controller(tuned.exports.interfaces.ExportableInterface): self._terminate.clear() # we have to pass some timeout, otherwise signals will not work - while not self._terminate.wait(3600): + while not tuned.utils.commands.wait(self._terminate, 3600): pass log.info("terminating controller") diff --git a/tuned/daemon/daemon.py b/tuned/daemon/daemon.py index 6d4c3d2..9741cac 100644 --- a/tuned/daemon/daemon.py +++ b/tuned/daemon/daemon.py @@ -3,6 +3,7 @@ import threading import tuned.logs from tuned.exceptions import TunedException import tuned.consts as consts +import tuned.utils.commands log = tuned.logs.get() @@ -65,7 +66,7 @@ class Daemon(object): self._unit_manager.start_tuning() self._terminate.clear() - while not self._terminate.wait(self._update_interval): + while not tuned.utils.commands.wait(self._terminate, self._update_interval): log.debug("updating monitors") self._unit_manager.update_monitors() log.debug("performing tunings") diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index 38bfaf9..9c5d459 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -85,3 +85,9 @@ def recommend_profile(): if match1 and match2: profile = section return profile + +def wait(terminate, time): + try: + return terminate.wait(time, False) + except: + return terminate.wait(time)