Overview
The GTK GUI uses GLib.timeout_add_seconds(2, self.refresh_connections) to refresh every 2 seconds. Inside refresh_connections(), it calls get_outgoing_connections() which iterates over all system processes via psutil — on the GTK main thread.
GTK is single-threaded. If get_outgoing_connections() takes longer than ~100ms, the UI will visibly stutter or freeze during the refresh.
This may not be a problem on all systems, but it's a structural risk worth measuring.
What needs to be done
Goal
Either confirm the current approach is fast enough and document it, or implement background threading to keep the UI responsive.
Notes
The GTK GLib.idle_add() pattern is the standard way to post results from a thread back to the GTK main loop. The worker thread must never call any Gtk.* methods directly.
Overview
The GTK GUI uses
GLib.timeout_add_seconds(2, self.refresh_connections)to refresh every 2 seconds. Insiderefresh_connections(), it callsget_outgoing_connections()which iterates over all system processes viapsutil— on the GTK main thread.GTK is single-threaded. If
get_outgoing_connections()takes longer than ~100ms, the UI will visibly stutter or freeze during the refresh.This may not be a problem on all systems, but it's a structural risk worth measuring.
What needs to be done
get_outgoing_connections()locally on a system with 50+ active connections — measure average execution time withtime.perf_counter()threading.Thread(target=self._refresh_worker, daemon=True)get_outgoing_connections()and post results back viaGLib.idle_add(self._update_ui, connections)Goal
Either confirm the current approach is fast enough and document it, or implement background threading to keep the UI responsive.
Notes
The GTK
GLib.idle_add()pattern is the standard way to post results from a thread back to the GTK main loop. The worker thread must never call anyGtk.*methods directly.