From 7bd2f67e19288db9b9df5d92bcb96621aba15e17 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Tue, 23 Sep 2025 23:40:09 +0200 Subject: [PATCH] Prevent librespot daemon getting into an endless loop --- music_assistant/providers/spotify_connect/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/music_assistant/providers/spotify_connect/__init__.py b/music_assistant/providers/spotify_connect/__init__.py index 900966f5..bdb23b2e 100644 --- a/music_assistant/providers/spotify_connect/__init__.py +++ b/music_assistant/providers/spotify_connect/__init__.py @@ -159,6 +159,7 @@ class SpotifyConnectProvider(PluginProvider): self._handle_custom_webservice, ), ] + self._runner_error_count = 0 async def handle_async_init(self) -> None: """Handle async initialization of the provider.""" @@ -245,8 +246,11 @@ class SpotifyConnectProvider(PluginProvider): if not self._librespot_started.is_set(): self.unload_with_error("Unable to initialize librespot daemon.") # auto restart if not stopped manually - if not self._stop_called and self._librespot_started.is_set(): - self._setup_player_daemon() + elif not self._stop_called and self._runner_error_count >= 5: + self.unload_with_error("Librespot daemon failed to start multiple times.") + elif not self._stop_called: + self._runner_error_count += 1 + self.mass.call_later(2, self._setup_player_daemon) def _setup_player_daemon(self) -> None: """Handle setup of the spotify connect daemon for a player.""" -- 2.34.1