From affbac4312958e6d8ae7fdd5d38d8e20e14e1ad8 Mon Sep 17 00:00:00 2001 From: NeonKirill Date: Sat, 14 Dec 2024 13:19:24 +0100 Subject: [PATCH] Fixed connectivity issue for klatchat observer --- services/klatchat_observer/controller.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/klatchat_observer/controller.py b/services/klatchat_observer/controller.py index 4f5dfa04..5d335929 100644 --- a/services/klatchat_observer/controller.py +++ b/services/klatchat_observer/controller.py @@ -112,6 +112,7 @@ def __init__( self.default_persona_llms = dict() + self.connect_sio() self.register_consumer( name="neon_response", vhost=self.get_vhost("neon_api"), @@ -356,7 +357,7 @@ def connect_sio(self): }, ) time.sleep(1) - LOG.info("Socket IO reconnected") + LOG.info("Socket IO connected") self.sio_connecting = False self.sio_connected = True while not self.sio_queued_messages.empty(): @@ -371,7 +372,7 @@ def sio(self): :return: connected async socket io instance """ - if not self.sio_connecting: + if not (self.sio_connected or self.sio_connecting): try: # Assuming that Socket IO is connected unless Exception is raised during the connection # This is done to prevent parallel invocation of this method from consumers @@ -909,5 +910,5 @@ def _sio_emit(self, event: str, data: dict): f"Socket IO event={event} emit failed due to error: {err}, reconnecting" ) self.sio_connected = False - else: + if not self.sio_connected: self.sio_queued_messages.put(item={"event": event, "data": data})