From 07380a48db75daf1de6d1dc7a2a116d96e4c9f91 Mon Sep 17 00:00:00 2001 From: Cam <yulinfeng000@gmail.com> Date: Mon, 30 Jan 2023 22:30:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=88=BF=E9=97=B4=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E8=8E=B7=E5=8F=96=E7=9B=B4=E6=92=AD=E9=97=B4?= =?UTF-8?q?ws=E5=9C=B0=E5=9D=80=E6=94=B9=E4=B8=BA=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E8=AF=B7=E6=B1=82/hotfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blive/eeframework.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/blive/eeframework.py b/blive/eeframework.py index 058bd2d..b62f1de 100644 --- a/blive/eeframework.py +++ b/blive/eeframework.py @@ -39,7 +39,6 @@ class BLiver(AsyncIOEventEmitter): self.aio_session = aiohttp.ClientSession() self.packman = BLiveMsgPackage() self.scheduler = AsyncIOScheduler(timezone="Asia/ShangHai") - self.aio_session = aiohttp.ClientSession() def register_handler(self, event: Union[Events, List[Events]], handler): warnings.warn( @@ -64,7 +63,7 @@ class BLiver(AsyncIOEventEmitter): await self.connect() # 重新连接 async def connect(self, retries=5): - for _ in range(retries): + for i in range(retries): try: if not hasattr(self,"real_room_id") or not hasattr(self,"uname"): self.real_room_id, self.uname = await get_blive_room_info( @@ -85,9 +84,9 @@ class BLiver(AsyncIOEventEmitter): asyncio.TimeoutError, ConnectionError, ConnectionResetError, - ): + ): await asyncio.sleep(1) - raise aiohttp.ClientConnectionError("与服务器连接失败") + # raise aiohttp.ClientConnectionError("与服务器连接失败") async def listen(self): self.running = True @@ -138,4 +137,4 @@ class BLiver(AsyncIOEventEmitter): def run_as_task(self): loop = asyncio.get_event_loop() - return loop.create_task(self.listen()) + return loop.create_task(self.listen()) \ No newline at end of file