catch provider timeout

This commit is contained in:
Roy Olav Purser 2021-05-27 20:39:29 +02:00
parent 05bc86a23f
commit 5969e24128
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -100,7 +100,11 @@ async def get_any(upstream, proxy, logger):
tasks.append(asyncio.create_task(get_ytdl(upstream, proxy, logger))) tasks.append(asyncio.create_task(get_ytdl(upstream, proxy, logger)))
result = None result = None
for task in asyncio.as_completed(tasks, timeout=5.0): for task in asyncio.as_completed(tasks, timeout=5.0):
temp_result = None
try:
temp_result = await task temp_result = await task
except Exception as e:
logger.info(e)
if isinstance(temp_result, str): if isinstance(temp_result, str):
result = temp_result result = temp_result
break break