Blob Blame History Raw
From a54b35c3b0c3b228eb924ed4ebfb964eead86cca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
Date: Fri, 14 Dec 2018 13:13:58 +0100
Subject: [PATCH] scheduler: Keep polling file objects alive long enough
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Make sure the file objects returned by evlist.get_pollfd()
don't go out of scope and get destroyed too soon. This is
a workaround for python3-perf rhbz#1659445.

Resolves: rhbz#1659140

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
---
 tuned/plugins/plugin_scheduler.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tuned/plugins/plugin_scheduler.py b/tuned/plugins/plugin_scheduler.py
index 93b6d91..22e49d3 100644
--- a/tuned/plugins/plugin_scheduler.py
+++ b/tuned/plugins/plugin_scheduler.py
@@ -448,7 +448,11 @@ class SchedulerPlugin(base.Plugin):
 	def _thread_code(self, instance):
 		r = self._cmd.re_lookup_compile(instance._sched_lookup)
 		poll = select.poll()
-		for fd in instance._evlist.get_pollfd():
+		# Store the file objects in a local variable so that they don't
+		# go out of scope too soon. This is a workaround for
+		# python3-perf bug rhbz#1659445.
+		fds = instance._evlist.get_pollfd()
+		for fd in fds:
 			poll.register(fd)
 		while not instance._terminate.is_set():
 			# timeout to poll in milliseconds
-- 
2.17.2