[PATCH v1 10/49] perf python: Allow KeyboardInterrupt to propagate in LiveSession
From: Ian Rogers
Date: Sun Sep 20 2026 - 01:26:34 EST
LiveSession.run() synchronously blocks while polling evlist for events.
When running interactive tools or scripts from the terminal,
KeyboardInterrupt exceptions raised via Ctrl-C must propagate so the
caller can break out of the polling loop.
Previously, LiveSession caught KeyboardInterrupt with an empty pass
statement, swallowing the exception and preventing calling scripts from
detecting the interrupt cleanly. Remove the empty handler so calling
scripts receive KeyboardInterrupt and can perform clean teardown.
Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/python/perf_live.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/perf/python/perf_live.py b/tools/perf/python/perf_live.py
index 616b5f657463..665699c5407a 100755
--- a/tools/perf/python/perf_live.py
+++ b/tools/perf/python/perf_live.py
@@ -36,7 +36,8 @@ class LiveSession:
except InterruptedError:
continue
for cpu in self.cpus:
- for _ in range(1000): # Limit to 1000 events per CPU per poll to prevent starvation
+ # Limit to 1000 events per CPU per poll to prevent starvation
+ for _ in range(1000):
try:
event = self.evlist.read_on_cpu(cpu)
except TypeError as e:
@@ -53,7 +54,5 @@ class LiveSession:
if event.type == perf.RECORD_SAMPLE:
self.sample_callback(event)
- except KeyboardInterrupt:
- pass
finally:
self.evlist.close()
--
2.55.0.1082.g2b9226bbc0-goog