From 522b9b06f8ec1e11cc1fd8a51254c0071b5f214f Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 7 Jul 2024 20:15:03 +0300 Subject: [PATCH] Suppress timeout error and die when we can --- async-bot.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/async-bot.py b/async-bot.py index 5d27064..ccf7d69 100644 --- a/async-bot.py +++ b/async-bot.py @@ -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: