From 1b68f14a7a1d652b720f5bccc92d3bcb964c5413 Mon Sep 17 00:00:00 2001 From: killian <63927363+KillianLucas@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:42:41 -0800 Subject: [PATCH] Better errors, bug fix --- 01OS/01OS/clients/base_device.py | 7 +++++-- 01OS/01OS/server/server.py | 2 +- 01OS/01OS/utils/accumulator.py | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/01OS/01OS/clients/base_device.py b/01OS/01OS/clients/base_device.py index 26ff235..a8e75d9 100644 --- a/01OS/01OS/clients/base_device.py +++ b/01OS/01OS/clients/base_device.py @@ -128,8 +128,11 @@ class Device: play(audio) self.audiosegments.remove(audio) await asyncio.sleep(0.1) + except asyncio.exceptions.CancelledError: + # This happens once at the start? + pass except: - logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) + logger.info(traceback.format_exc()) def record_audio(self): @@ -282,7 +285,7 @@ class Device: except: - logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) + logger.debug(traceback.format_exc()) logger.info(f"Connecting to `{WS_URL}`...") await asyncio.sleep(2) diff --git a/01OS/01OS/server/server.py b/01OS/01OS/server/server.py index 3ac559b..e954e96 100644 --- a/01OS/01OS/server/server.py +++ b/01OS/01OS/server/server.py @@ -102,7 +102,7 @@ async def websocket_endpoint(websocket: WebSocket): try: await asyncio.gather(receive_task, send_task) except Exception as e: - logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) + logger.debug(traceback.format_exc()) logger.info(f"Connection lost. Error: {e}") async def receive_messages(websocket: WebSocket): diff --git a/01OS/01OS/utils/accumulator.py b/01OS/01OS/utils/accumulator.py index 5b039e2..b6353cd 100644 --- a/01OS/01OS/utils/accumulator.py +++ b/01OS/01OS/utils/accumulator.py @@ -17,6 +17,10 @@ class Accumulator: return None if "content" in chunk: + + # Display + print(chunk['content'], end="", flush=True) + if any(self.message[key] != chunk[key] for key in self.message if key != "content"): self.message = chunk if "content" not in self.message: