From dfa6af05c9e6f49934ac3760997b60581f0bdb4f Mon Sep 17 00:00:00 2001 From: trav Date: Sat, 22 Aug 2026 13:15:42 -0400 Subject: [PATCH] v0.10.1: ending a cast no longer freezes the window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit serve_forever's poll_interval is how long shutdown() blocks waiting for the loop to notice it should stop, and the default is 0.5 s. That whole half second was paid on the GUI thread every time a cast session ended: the click on the cast indicator goes disconnect() → _teardown → sink.shutdown() → server.stop() → httpd.shutdown(), all synchronous. Measured here: 450 ms of frozen window, now 10 ms. The cost is 100 select() wakeups a second instead of 2, on a thread that only exists for the life of a cast session. Found uncommitted in the working tree, left over from the cast round. Claude-Session: https://claude.ai/code/session_01G4Z46BMQYS57bcbxWbSS3C --- lintunes/__init__.py | 2 +- lintunes/cast/server.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lintunes/__init__.py b/lintunes/__init__.py index d96b3c3..9b6daee 100644 --- a/lintunes/__init__.py +++ b/lintunes/__init__.py @@ -1,3 +1,3 @@ """LinTunes — iTunes-style music library manager and player for Linux.""" -__version__ = "0.10.0" +__version__ = "0.10.1" diff --git a/lintunes/cast/server.py b/lintunes/cast/server.py index 4ae472b..749e776 100644 --- a/lintunes/cast/server.py +++ b/lintunes/cast/server.py @@ -157,7 +157,11 @@ class TrackServer: httpd.daemon_threads = True httpd.track_server = self self._httpd = httpd - self._thread = threading.Thread(target=httpd.serve_forever, daemon=True) + # poll_interval is how long shutdown() may block waiting for the + # serve_forever loop to notice: the default 0.5 s is paid on the GUI + # thread every time a cast session ends. + self._thread = threading.Thread( + target=lambda: httpd.serve_forever(poll_interval=0.01), daemon=True) self._thread.start() return self.port