From f65a2e5d0be3b66c8b25fab41afcef631be56bdf Mon Sep 17 00:00:00 2001 From: gsd Date: Mon, 16 Sep 2024 23:13:12 +0300 Subject: [PATCH] timeout fix --- backend/config_parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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}")