Fix async/sync load issues with knowledge streaming APIs (#315)

This commit is contained in:
cybermaggedon 2025-03-15 12:38:10 +00:00 committed by GitHub
parent c08779ff3c
commit a922852017
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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()