From a298ef8d7452fff5b96a4c7f80ebcda73206eaae Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 28 Oct 2024 09:41:38 -0400 Subject: [PATCH] Catch OpenBMC disconnects and handle them better --- confluent_server/confluent/plugins/console/openbmc.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/plugins/console/openbmc.py b/confluent_server/confluent/plugins/console/openbmc.py index 3ff08e5a..a67d9b23 100644 --- a/confluent_server/confluent/plugins/console/openbmc.py +++ b/confluent_server/confluent/plugins/console/openbmc.py @@ -124,7 +124,10 @@ class TsmConsole(conapi.Console): def recvdata(self): while self.connected: - pendingdata = self.ws.recv() + try: + pendingdata = self.ws.recv() + except websocket.WebSocketConnectionClosedException: + pendingdata = '' if pendingdata == '': self.datacallback(conapi.ConsoleEvent.Disconnect) return @@ -153,7 +156,10 @@ class TsmConsole(conapi.Console): return def write(self, data): - self.ws.send(data) + try: + self.ws.send(data) + except websocket.WebSocketConnectionClosedException: + self.datacallback(conapi.ConsoleEvent.Disconnect) def close(self): if self.recvr: