mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-15 15:53:44 +00:00
Add timeout to known download exceptions
This commit is contained in:
@@ -3,10 +3,11 @@ import asyncio
|
|||||||
import logging
|
import logging
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
|
from asyncio.exceptions import TimeoutError
|
||||||
from typing import Callable, List, Optional
|
from typing import Callable, List, Optional
|
||||||
|
|
||||||
import aiocron
|
import aiocron
|
||||||
import aiohttp
|
from aiohttp.client_exceptions import ClientPayloadError
|
||||||
from pyunifiprotect import NvrError, ProtectApiClient
|
from pyunifiprotect import NvrError, ProtectApiClient
|
||||||
from pyunifiprotect.data.nvr import Event
|
from pyunifiprotect.data.nvr import Event
|
||||||
from pyunifiprotect.data.types import EventType, ModelType
|
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)
|
video = await self._protect.get_camera_video(event.camera_id, event.start, event.end)
|
||||||
assert isinstance(video, bytes)
|
assert isinstance(video, bytes)
|
||||||
break
|
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.warn(f" Failed download attempt {x+1}, retying in 1s")
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user