Skip to content

A GPU task manager for Windows, Linux, and WSL: per-process VRAM, GPU activity, and LLM model/KV-cache insights (Windows AMD and NVIDIA).

Python

Ignore row highlights after the inspector is removed

jihoo3381d2d11848
diff --git a/src/gputaskman/app.py b/src/gputaskman/app.py
index c8e68e3..4fbc7ba 100644
--- a/src/gputaskman/app.py
+++ b/src/gputaskman/app.py
@@ -615,7 +615,11 @@ class GpuTaskManager(App):
t.border_subtitle = WSL_EMPTY
def render_inspector(self) -> None:
- panel = self.query_one("#inspector", Static)
+ # A queued RowHighlighted can arrive while the screen is being torn down, after the
+ # inspector is gone. Nothing is left to render then, so ignore it instead of raising.
+ panel = next(iter(self.query("#inspector")), None)
+ if panel is None:
+ return
s = self._row_snapshots.get(self.selected_key, self.snap)
r = next((x for x in s.procs if x.key == self.selected_key), None) if s else None
if r is None:
diff --git a/tests/test_core.py b/tests/test_core.py
index 4652fcd..28b586a 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1102,6 +1102,18 @@ class UiTests(unittest.IsolatedAsyncioTestCase):
app.hist_clock.clear()
self.assertEqual(app.chart_series(index, None)[1], 1)
+ async def test_row_highlight_after_the_inspector_is_gone_is_ignored(self):
+ # During teardown a queued RowHighlighted can arrive after the inspector was removed
+ # (observed on Windows 3.11 CI). It must not raise NoMatches out of run_test.
+ with patch.object(GpuTaskManager, "poll"):
+ app = GpuTaskManager()
+ async with app.run_test(size=(140, 42)) as pilot:
+ app.apply(snapshot())
+ await pilot.pause()
+ app.query_one("#inspector").remove()
+ await pilot.pause()
+ app.render_inspector()
+
async def test_unavailable_device_metrics_render_as_na(self):
with patch.object(GpuTaskManager, "poll"):
app = GpuTaskManager()