Added try guard to sio.receive in writer

This commit is contained in:
Casey 2024-07-07 19:36:33 +03:00
parent 5df9dd4598
commit 4527954cad
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 6 additions and 2 deletions

View File

@ -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,
)