Skip to content

Commit

Permalink
Fixed connectivity issue for klatchat observer
Browse files Browse the repository at this point in the history
  • Loading branch information
kirgrim committed Dec 14, 2024
1 parent 98322a4 commit affbac4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions services/klatchat_observer/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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():
Expand All @@ -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
Expand Down Expand Up @@ -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})

0 comments on commit affbac4

Please sign in to comment.