Suppress timeout error and die when we can
This commit is contained in:
parent
18b9333a80
commit
522b9b06f8
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue