mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
refactor: improve error handling in anime refresh loop
- Reorganized the try-except structure in the _refresh_loop method for better readability and clarity. - Ensured that the error handling for asyncio.CancelledError and other exceptions is properly nested within the loop.
This commit is contained in:
@@ -230,14 +230,14 @@ class AnimeMapper:
|
||||
return entry[key]
|
||||
|
||||
async def _refresh_loop(self, interval: int):
|
||||
try:
|
||||
while True:
|
||||
while True:
|
||||
try:
|
||||
await asyncio.sleep(interval)
|
||||
await self._refresh_from_remote(background=True)
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
logger.warning(f"Anime mapping refresh loop encountered an error: {exc}")
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
logger.warning(f"Anime mapping refresh loop encountered an error: {exc}")
|
||||
|
||||
async def stop(self):
|
||||
if self._background_task:
|
||||
|
||||
Reference in New Issue
Block a user