From c99e150fff440a9a6889c13821a1bce6c710a016 Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 7 Jul 2024 21:37:21 +0300 Subject: [PATCH] Don't shut down if didn't talk much before --- async-bot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/async-bot.py b/async-bot.py index c5b4210..f83f192 100644 --- a/async-bot.py +++ b/async-bot.py @@ -39,6 +39,7 @@ class AsyncBotManager: self._written_boxes = 0 self._read_boxes = 0 self._last_printout = time_now() + self._n_printouts = 0 self._active: set[int] = set() self.reader_event = asyncio.Event() @@ -199,11 +200,13 @@ class AsyncBotManager: print(f"I/O: {incoming:7.2f}/s | {outgoing:7.2f}/s") print(f"Alive workers: {len(self._active)}") - if len(self._active) < 2: + if len(self._active) < 2 and self._n_printouts > 3: print("Too few workers, dying!") self._shutdown = True return + self._n_printouts += 1 + n_correct, n_wrong = 0, 0 for index, expected in self.difference.items(): y, x = divmod(index, 1000)