fix(fetcher): fix unretieved exceptions

This commit is contained in:
MingxuanGame
2025-11-09 09:37:59 +08:00
parent 2bd770a995
commit 3a00ca9b91

View File

@@ -91,11 +91,17 @@ class BeatmapRawFetcher(BaseFetcher):
try: try:
# 实际执行请求 # 实际执行请求
result = await self._fetch_beatmap_raw(beatmap_id) result = await self._fetch_beatmap_raw(beatmap_id)
future.set_result(result) if not future.done():
future.set_result(result)
return result return result
except Exception as e: except asyncio.CancelledError:
future.set_exception(e) if not future.done():
future.cancel()
raise raise
except Exception as e:
if not future.done():
future.set_exception(e)
return await future
finally: finally:
# 清理 # 清理
async with self._request_lock: async with self._request_lock:
@@ -153,3 +159,4 @@ class BeatmapRawFetcher(BaseFetcher):
raw = await self.get_beatmap_raw(beatmap_id) raw = await self.get_beatmap_raw(beatmap_id)
await redis.set(cache_key, raw, ex=cache_expire) await redis.set(cache_key, raw, ex=cache_expire)
return raw return raw