From 4edd936cb67c94a1872247b0ddc45f10e2e05ddf Mon Sep 17 00:00:00 2001 From: Radhakrishnan Sethuraman Date: Mon, 9 Dec 2024 17:31:47 -0600 Subject: [PATCH] reduce retries --- unifi_protect_backup/downloader.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/unifi_protect_backup/downloader.py b/unifi_protect_backup/downloader.py index b746ca6..5bd0bf9 100644 --- a/unifi_protect_backup/downloader.py +++ b/unifi_protect_backup/downloader.py @@ -175,8 +175,9 @@ class VideoDownloader: async def _download(self, event: Event) -> Optional[bytes]: """Downloads the video clip for the given event.""" - self.logger.debug(" Downloading video...") - for x in range(5): + + for x in range(3): + self.logger.debug(" Downloading video...") assert isinstance(event.camera_id, str) assert isinstance(event.start, datetime) assert isinstance(event.end, datetime) @@ -191,9 +192,9 @@ class VideoDownloader: break except (AssertionError, ClientPayloadError, TimeoutError) as e: self.logger.warning(f" Failed download attempt {x+1}, retying in 1s", exc_info=e) - await asyncio.sleep(0.5) + await asyncio.sleep(1) else: - self.logger.error(f"Download failed after 5 attempts, abandoning event {event.id}:") + self.logger.error(f"Download failed after 3 attempts, abandoning event {event.id}:") return None self.logger.debug(f" Downloaded video size: {human_readable_size(len(video))}s")