add task timeout
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user