Fix async/sync load issues with knowledge streaming APIs

This commit is contained in:
Cyber MacGeddon 2025-03-15 12:14:51 +00:00
parent 88768a791b
commit 7cf9299698
5 changed files with 6 additions and 8 deletions

View file

@ -59,6 +59,6 @@ class DocumentEmbeddingsLoadEndpoint(SocketEndpoint):
],
)
await self.publisher.send(None, elt)
self.publisher.send(None, elt)
running.stop()

View file

@ -36,6 +36,7 @@ class GraphEmbeddingsLoadEndpoint(SocketEndpoint):
async def listener(self, ws, running):
async for msg in ws:
# On error, finish
if msg.type == WSMsgType.ERROR:
break
@ -59,7 +60,6 @@ class GraphEmbeddingsLoadEndpoint(SocketEndpoint):
]
)
await self.publisher.send(None, elt)
self.publisher.send(None, elt)
running.stop()

View file

@ -53,11 +53,9 @@ class ServiceRequestor:
q = self.sub.subscribe(id)
print("BOUT TO SEDN")
await asyncio.to_thread(
self.pub.send, id, self.to_request(request)
)
print("SENT")
while True:

View file

@ -19,7 +19,7 @@ class SocketEndpoint:
self.operation = "socket"
async def listener(self, ws, running):
async for msg in ws:
# On error, finish
if msg.type == WSMsgType.TEXT:
@ -53,7 +53,7 @@ class SocketEndpoint:
try:
await self.listener(ws, running)
except Exception as e:
print(e, flush=True)
print("Socket exception:", e, flush=True)
running.stop()

View file

@ -51,7 +51,7 @@ class TriplesLoadEndpoint(SocketEndpoint):
triples=to_subgraph(data["triples"]),
)
await self.publisher.send(None, elt)
self.publisher.send(None, elt)
running.stop()