Add timeout to known download exceptions

This commit is contained in:
Sebastian Goscik
2022-02-22 22:57:50 +00:00
parent 90e50fd982
commit 3e53d43f95

View File

@@ -3,10 +3,11 @@ import asyncio
import logging
import pathlib
import shutil
from asyncio.exceptions import TimeoutError
from typing import Callable, List, Optional
import aiocron
import aiohttp
from aiohttp.client_exceptions import ClientPayloadError
from pyunifiprotect import NvrError, ProtectApiClient
from pyunifiprotect.data.nvr import Event
from pyunifiprotect.data.types import EventType, ModelType
@@ -380,7 +381,7 @@ class UnifiProtectBackup:
video = await self._protect.get_camera_video(event.camera_id, event.start, event.end)
assert isinstance(video, bytes)
break
except (AssertionError, aiohttp.client_exceptions.ClientPayloadError) as e:
except (AssertionError, ClientPayloadError, TimeoutError) as e:
logger.warn(f" Failed download attempt {x+1}, retying in 1s")
logger.exception(e)
await asyncio.sleep(1)