From 3a00ca9b91f6fb7fcee7be2954bfa77832884402 Mon Sep 17 00:00:00 2001 From: MingxuanGame Date: Sun, 9 Nov 2025 09:37:59 +0800 Subject: [PATCH] fix(fetcher): fix unretieved exceptions --- app/fetcher/beatmap_raw.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/fetcher/beatmap_raw.py b/app/fetcher/beatmap_raw.py index 6785863..2e52a42 100644 --- a/app/fetcher/beatmap_raw.py +++ b/app/fetcher/beatmap_raw.py @@ -91,11 +91,17 @@ class BeatmapRawFetcher(BaseFetcher): try: # 实际执行请求 result = await self._fetch_beatmap_raw(beatmap_id) - future.set_result(result) + if not future.done(): + future.set_result(result) return result - except Exception as e: - future.set_exception(e) + except asyncio.CancelledError: + if not future.done(): + future.cancel() raise + except Exception as e: + if not future.done(): + future.set_exception(e) + return await future finally: # 清理 async with self._request_lock: @@ -153,3 +159,4 @@ class BeatmapRawFetcher(BaseFetcher): raw = await self.get_beatmap_raw(beatmap_id) await redis.set(cache_key, raw, ex=cache_expire) return raw +