From 4bac836d6e6d6ed75b9ce5f6369f3bb5d71b6dd4 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 26 Apr 2025 21:08:12 +0100 Subject: [PATCH] Fixed starting and stopping rsi in the cli. Tidied up print statements, converted to logging. Tidied up comments. --- src/RSIPI/rsi_client.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/RSIPI/rsi_client.py b/src/RSIPI/rsi_client.py index e53bc79..367a2f1 100644 --- a/src/RSIPI/rsi_client.py +++ b/src/RSIPI/rsi_client.py @@ -54,20 +54,23 @@ class RSIClient: def stop(self): """Stop the network process and the client thread safely.""" - logging.info("Stopping RSI Client...") + logging.info("🛑 Stopping RSI Client...") self.running = False - self.stop_event.set() + self.stop_event.set() # ✅ Tell network process to exit nicely if self.network_process and self.network_process.is_alive(): - self.network_process.terminate() - self.network_process.join() + self.network_process.join(timeout=3) # ✅ Give it time to shutdown + if self.network_process.is_alive(): + logging.warning("⚠️ Forcing network process termination...") + self.network_process.terminate() + self.network_process.join() if hasattr(self, "thread") and self.thread and self.thread.is_alive(): self.thread.join() self.thread = None - self.reconnect() - logging.info("RSI Client Stopped") + + logging.info("✅ RSI Client Stopped") def reconnect(self): """Reconnects the network process safely."""