add task timeout

This commit is contained in:
Roy Olav Purser 2021-05-20 14:00:01 +02:00
parent 28efc2aa6c
commit 409edcd6c7
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -22,7 +22,6 @@ class StreamProvider():
class StreamlinkRunner(StreamProvider):
def stream(self):
session = streamlink.Streamlink()
session.set_option("http-timeout", 2.0)
if self.proxy is not None:
session.set_option("https-proxy", self.proxy)
session.set_option("http-proxy", self.proxy)
@ -92,7 +91,7 @@ async def get_any(upstream, proxy, logger):
tasks.append(asyncio.create_task(get_streamlink(upstream, proxy, logger)))
tasks.append(asyncio.create_task(get_ytdl(upstream, proxy, logger)))
result = None
for task in asyncio.as_completed(tasks):
for task in asyncio.as_completed(tasks, timeout=2.0):
result = await task
if isinstance(result, str):
break