fix: Fixed an issue where the calculation of waiting time was incorrect when the number of users was 0 or too low

This commit is contained in:
LWR
2023-05-21 17:18:19 +08:00
parent e2dbef8739
commit 59ceed81e5
2 changed files with 14 additions and 13 deletions
+8 -7
View File
@@ -117,13 +117,14 @@ class StarBot:
await asyncio.sleep(0.2)
except LiveException as ex:
logger.error(ex.msg)
try:
wait_time = config.get("WAIT_FOR_ALL_CONNECTION_TIMEOUT")
if wait_time == 0:
wait_time = len(self.__datasource.get_up_list()) // 5 * 2
await asyncio.wait_for(self.__datasource.wait_for_connects(), wait_time)
except asyncio.exceptions.TimeoutError:
logger.warning("等待连接所有直播间超时, 请检查是否存在未连接成功的直播间")
if len(self.__datasource.get_up_list()) > 0:
try:
wait_time = config.get("WAIT_FOR_ALL_CONNECTION_TIMEOUT")
if wait_time == 0:
wait_time = (len(self.__datasource.get_up_list()) + 5) // 5 * 2
await asyncio.wait_for(self.__datasource.wait_for_connects(), wait_time)
except asyncio.exceptions.TimeoutError:
logger.warning("等待连接所有直播间超时, 请检查是否存在未连接成功的直播间")
# 启动动态推送模块
asyncio.get_event_loop().create_task(dynamic_spider(self.__datasource))