v0.10.1: ending a cast no longer freezes the window

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.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G4Z46BMQYS57bcbxWbSS3C
This commit is contained in:
2026-08-22 13:15:42 -04:00
co-authored by Claude Opus 5
parent 9ef59dd3b2
commit 4b510318c6
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux.""" """LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.10.0" __version__ = "0.10.1"
+5 -1
View File
@@ -157,7 +157,11 @@ class TrackServer:
httpd.daemon_threads = True httpd.daemon_threads = True
httpd.track_server = self httpd.track_server = self
self._httpd = httpd 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() self._thread.start()
return self.port return self.port