add task timeout
This commit is contained in:
parent
28efc2aa6c
commit
409edcd6c7
@ -22,7 +22,6 @@ class StreamProvider():
|
|||||||
class StreamlinkRunner(StreamProvider):
|
class StreamlinkRunner(StreamProvider):
|
||||||
def stream(self):
|
def stream(self):
|
||||||
session = streamlink.Streamlink()
|
session = streamlink.Streamlink()
|
||||||
session.set_option("http-timeout", 2.0)
|
|
||||||
if self.proxy is not None:
|
if self.proxy is not None:
|
||||||
session.set_option("https-proxy", self.proxy)
|
session.set_option("https-proxy", self.proxy)
|
||||||
session.set_option("http-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_streamlink(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):
|
for task in asyncio.as_completed(tasks, timeout=2.0):
|
||||||
result = await task
|
result = await task
|
||||||
if isinstance(result, str):
|
if isinstance(result, str):
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user