mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-03 20:32:38 +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()
|
running.stop()
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue