From 4527954cadb83ea1c764a2934c30704f9946bd8c Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 7 Jul 2024 19:36:33 +0300 Subject: [PATCH] Added try guard to sio.receive in writer --- async-bot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/async-bot.py b/async-bot.py index c0c55d8..f1c5a9a 100644 --- a/async-bot.py +++ b/async-bot.py @@ -1,6 +1,7 @@ import asyncio from typing import Callable, NewType, Optional from socketio import AsyncClient, AsyncSimpleClient +import socketio from aiohttp import ClientSession, ClientTimeout from aiohttp_socks import ProxyConnector from PIL import Image, ImageFont, ImageDraw, ImageFilter, ImageSequence, ImageChops @@ -255,7 +256,10 @@ class AsyncBotManager: await sio.emit("toggle_bit", {"index": index}) await asyncio.sleep(delay) self._active.add(bot_index) - await sio.receive(0.1) + try: + await sio.receive(0.1) + except socketio.exceptions.TimeoutError: + print(f"read failed in {bot_index}") async def __aenter__(self): self._listener_task = asyncio.create_task(self.listener()) @@ -412,7 +416,7 @@ async def amain() -> None: ) else: res = await asyncio.gather( - *[mgr.writer(i) for i in range(settings["n_bots"])], + *[mgr.writer(i, None, settings["delay"]) for i in range(settings["n_bots"])], return_exceptions=True, )