From 683e272b4d2e93c6fb1e510cdf98b969e3e8d9c3 Mon Sep 17 00:00:00 2001 From: Estrella Pan Date: Sun, 25 Jan 2026 09:58:55 +0100 Subject: [PATCH] fix(core): add max retry for downloader connection check Prevents startup from hanging indefinitely when downloader is unreachable (e.g., due to proxy configuration). After 10 retries (~5 min), program continues with an error log instead of blocking. Fixes #955 (comment) Co-Authored-By: Claude Opus 4.5 --- backend/src/module/core/program.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/src/module/core/program.py b/backend/src/module/core/program.py index 28da2a88..ac27dfd4 100644 --- a/backend/src/module/core/program.py +++ b/backend/src/module/core/program.py @@ -71,9 +71,21 @@ class Program(RenameThread, RSSThread): async def start(self): self.stop_event.clear() settings.load() + max_retries = 10 + retry_count = 0 while not await self.check_downloader_status(): - logger.warning("Downloader is not running.") - logger.info("Waiting for downloader to start.") + retry_count += 1 + logger.warning( + f"Downloader is not running. (attempt {retry_count}/{max_retries})" + ) + if retry_count >= max_retries: + logger.error( + "Failed to connect to downloader after maximum retries. " + "Please check downloader settings and network/proxy configuration. " + "Program will continue but download functions will not work." + ) + break + logger.info("Waiting for downloader to start...") await asyncio.sleep(30) if self.enable_renamer: self.rename_start()