From cdefe91ee13c4c6f98ff03f98cb93333886a3094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Wed, 12 Apr 2017 15:52:52 +0200 Subject: [PATCH] scheduler: do not traceback if process dissapears during enumeration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jaroslav Škarvada --- tuned/plugins/plugin_scheduler.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tuned/plugins/plugin_scheduler.py b/tuned/plugins/plugin_scheduler.py index 36077d8..8ec7ca6 100644 --- a/tuned/plugins/plugin_scheduler.py +++ b/tuned/plugins/plugin_scheduler.py @@ -343,15 +343,20 @@ class SchedulerPlugin(base.Plugin): if not threads and objs[obj].has_key("threads"): self._set_all_obj_affinity(dict(objs[obj]["threads"].items()), affinity, True, intersect) + def _get_stat_comm(self, o): + try: + return o["stat"]["comm"] + except (OSError, IOError, KeyError): + return "" def _set_ps_affinity(self, affinity, intersect = False): _affinity = affinity affinity_hex = self._cmd.cpulist2hex(_affinity) ps = procfs.pidstats() ps.reload_threads() - psl = filter(lambda v: re.search(self._ps_whitelist, v["stat"]["comm"]) is not None, ps.values()) + psl = filter(lambda v: re.search(self._ps_whitelist, self._get_stat_comm(v)) is not None, ps.values()) if self._ps_blacklist != "": - psl = filter(lambda v: re.search(self._ps_blacklist, v["stat"]["comm"]) is None, psl) + psl = filter(lambda v: re.search(self._ps_blacklist, self._get_stat_comm(v)) is None, psl) psd = dict(map(lambda v: (v.pid, v), psl)) self._set_all_obj_affinity(psd, affinity, False, intersect)