diff --git a/starbot/core/bot.py b/starbot/core/bot.py index 4d78817..c2421ac 100644 --- a/starbot/core/bot.py +++ b/starbot/core/bot.py @@ -111,10 +111,11 @@ class StarBot: await redis.set_live_start_time(up.room_id, start_time) # 连接直播间 + interval = config.get("CONNECTION_INTERVAL") for up in self.__datasource.get_up_list(): try: await up.connect() - await asyncio.sleep(0.2) + await asyncio.sleep(interval) except LiveException as ex: logger.error(ex.msg) if len(self.__datasource.get_up_list()) > 0: diff --git a/starbot/utils/config.py b/starbot/utils/config.py index 34c0517..aba2fa1 100644 --- a/starbot/utils/config.py +++ b/starbot/utils/config.py @@ -44,6 +44,8 @@ SIMPLE_CONFIG = { # 是否将日志同时输出到文件中 "LOG_TO_FILE": False, + # 连接每个直播间的间隔等待时长,用于避免连接大量直播间时的并发过多异常 too many file descriptors in select(),单位:秒 + "CONNECTION_INTERVAL": 0.2, # 成功连接所有主播直播间的最大等待时长,可使得日志输出顺序更加易读,一般无需修改此处,设置为 0 会自适应计算,单位:秒 "WAIT_FOR_ALL_CONNECTION_TIMEOUT": 0, @@ -160,6 +162,8 @@ FULL_CONFIG = { # 是否将日志同时输出到文件中 "LOG_TO_FILE": False, + # 连接每个直播间的间隔等待时长,用于避免连接大量直播间时的并发过多异常 too many file descriptors in select(),单位:秒 + "CONNECTION_INTERVAL": 0.2, # 成功连接所有主播直播间的最大等待时长,可使得日志输出顺序更加易读,一般无需修改此处,设置为 0 会自适应计算,单位:秒 "WAIT_FOR_ALL_CONNECTION_TIMEOUT": 0,