mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Fix async/sync load issues with knowledge streaming APIs (#315)
This commit is contained in:
parent
c08779ff3c
commit
a922852017
5 changed files with 6 additions and 8 deletions
|
|
@ -59,6 +59,6 @@ class DocumentEmbeddingsLoadEndpoint(SocketEndpoint):
|
|||
],
|
||||
)
|
||||
|
||||
await self.publisher.send(None, elt)
|
||||
self.publisher.send(None, elt)
|
||||
|
||||
running.stop()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue