diff --git a/backend/config_parser.py b/backend/config_parser.py index af9e035..8446ba3 100644 --- a/backend/config_parser.py +++ b/backend/config_parser.py @@ -329,11 +329,13 @@ class TranscodeTools: if not os.path.exists(raw_file) or os.path.getsize(raw_file) == 0: try: await nvr.login() - async with asyncio.timeout(10): + async def download_task(): self.logger.info(f"download new preview {preview_file}") async with aiofiles.open(raw_file, "wb") as raw: async for chunk in nvr.stream_file(file, preview_pre_bytes): await raw.write(chunk) + await asyncio.wait_for(download_task(), 10) + except asyncio.TimeoutError as te: clear_from_storage() self.logger.info(f"Cancel download file: {te}")