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 <noreply@anthropic.com>
This commit is contained in:
Estrella Pan
2026-01-25 09:58:55 +01:00
parent 609aa9b505
commit 683e272b4d

View File

@@ -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()