diff --git a/media_downloader.py b/media_downloader.py index d56712e..02fbe7c 100644 --- a/media_downloader.py +++ b/media_downloader.py @@ -705,11 +705,18 @@ async def download_chat_task( update_task_progress(estimated_total=actual_total, is_checking=False) -async def _wait_node_finish(chat_config): - """等待单个频道的所有下载任务完成(含重试中的任务)""" +async def _wait_node_finish(chat_config, timeout: int = 3600): + """等待单个频道的所有下载任务完成(含重试中的任务),超时后强制跳过避免队列卡死""" + deadline = asyncio.get_event_loop().time() + timeout while True: if chat_config.need_check and chat_config.finish_task >= chat_config.total_task: break + if asyncio.get_event_loop().time() > deadline: + logger.warning( + f"等待频道任务完成超时({timeout}s),强制跳过," + f"finish={chat_config.finish_task} total={chat_config.total_task}" + ) + break await asyncio.sleep(0.5)