Suppress timeout error and die when we can

This commit is contained in:
Casey 2024-07-07 20:15:03 +03:00
parent 18b9333a80
commit 522b9b06f8
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 2 additions and 5 deletions

View File

@ -10,6 +10,7 @@ from random import choice, randint
from json import load
from time import time as time_now
import datetime
from contextlib import suppress
PixelMap = NewType("PixelMap", dict[int, bool])
@ -256,10 +257,8 @@ class AsyncBotManager:
await sio.emit("toggle_bit", {"index": index})
await asyncio.sleep(delay)
self._active.add(bot_index)
try:
with suppress():
await sio.receive(0.1)
except TimeoutError:
pass
async def __aenter__(self):
self._listener_task = asyncio.create_task(self.listener())
@ -412,12 +411,10 @@ async def amain() -> None:
)
for i in range(settings["n_bots"])
],
return_exceptions=True,
)
else:
res = await asyncio.gather(
*[mgr.writer(i, None, settings["delay"]) for i in range(settings["n_bots"])],
return_exceptions=True,
)
for ret in res: