mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-28 09:56:22 +02:00
Maint/asyncio (#305)
* Move to asyncio services, even though everything is largely sync
This commit is contained in:
parent
a0bf2362f6
commit
f350abb415
60 changed files with 243 additions and 227 deletions
|
|
@ -40,7 +40,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
self.vecstore = DocVectors(store_uri)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = DocumentEmbeddingsResponse(documents=chunks, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ class Processor(ConsumerProducer):
|
|||
documents=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -102,5 +102,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class Processor(ConsumerProducer):
|
|||
}
|
||||
)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = DocumentEmbeddingsResponse(documents=chunks, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ class Processor(ConsumerProducer):
|
|||
documents=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -143,5 +143,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
self.client = QdrantClient(url=store_uri, api_key=api_key)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = DocumentEmbeddingsResponse(documents=chunks, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ class Processor(ConsumerProducer):
|
|||
documents=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -125,5 +125,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class Processor(ConsumerProducer):
|
|||
else:
|
||||
return Value(value=ent, is_uri=False)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = GraphEmbeddingsResponse(entities=entities, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ class Processor(ConsumerProducer):
|
|||
entities=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -117,5 +117,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Processor(ConsumerProducer):
|
|||
else:
|
||||
return Value(value=ent, is_uri=False)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = GraphEmbeddingsResponse(entities=entities, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ class Processor(ConsumerProducer):
|
|||
entities=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -163,5 +163,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Processor(ConsumerProducer):
|
|||
else:
|
||||
return Value(value=ent, is_uri=False)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = GraphEmbeddingsResponse(entities=entities, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ class Processor(ConsumerProducer):
|
|||
entities=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -150,5 +150,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class Processor(ConsumerProducer):
|
|||
else:
|
||||
return Value(value=ent, is_uri=False)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = TriplesQueryResponse(triples=triples, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ class Processor(ConsumerProducer):
|
|||
response=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -205,5 +205,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Processor(ConsumerProducer):
|
|||
else:
|
||||
return Value(value=ent, is_uri=False)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -301,7 +301,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = TriplesQueryResponse(triples=triples, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ class Processor(ConsumerProducer):
|
|||
response=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -345,5 +345,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Processor(ConsumerProducer):
|
|||
else:
|
||||
return Value(value=ent, is_uri=False)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = TriplesQueryResponse(triples=triples, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ class Processor(ConsumerProducer):
|
|||
response=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -369,5 +369,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Processor(ConsumerProducer):
|
|||
else:
|
||||
return Value(value=ent, is_uri=False)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
try:
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
print("Send response...", flush=True)
|
||||
r = TriplesQueryResponse(triples=triples, error=None)
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ class Processor(ConsumerProducer):
|
|||
response=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.send(r, properties={"id": id})
|
||||
|
||||
self.consumer.acknowledge(msg)
|
||||
|
||||
|
|
@ -353,5 +353,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue