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() running.stop()

View file

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

View file

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

View file

@ -53,7 +53,7 @@ class SocketEndpoint:
try: try:
await self.listener(ws, running) await self.listener(ws, running)
except Exception as e: except Exception as e:
print(e, flush=True) print("Socket exception:", e, flush=True)
running.stop() running.stop()

View file

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