From f8b18ded00186c3ba0b39775bbab587bb39232d8 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Sat, 19 Apr 2025 17:49:38 +0300 Subject: [PATCH] wrap cancel in try catch to avoid possible problems. --- app/library/DownloadQueue.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index ba1d3b5d..fa39f67e 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -751,11 +751,13 @@ class DownloadQueue(metaclass=Singleton): LOG.debug("Checking for stale items in the download queue.") for id, item in list(self.queue.items()): + item_ref = f"{id=} {item.info.id=} {item.info.title=}" if not item.is_stale(): - LOG.debug(f"Item '{item.info.id}: {item.info.title}: {item.info.status}' is not stale.") + LOG.debug(f"Item '{item_ref}' is not stale.") continue - LOG.warning( - f"Cancelling staled item '{item.info.id}: {item.info.title}: {item.info.status}' download queue." - ) - self.cancel([id]) + LOG.warning(f"Cancelling staled item '{item_ref}' from download queue.") + try: + await self.cancel([id]) + except Exception as e: + LOG.error(f"Failed to cancel staled item '{item_ref}'. {e!s}")