mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-05-03 04:12:37 +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
|
|
@ -52,7 +52,7 @@ class Processor(ConsumerProducer):
|
|||
subscriber=module + "-emb",
|
||||
)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
v = msg.value()
|
||||
print(f"Indexing {v.metadata.id}...", flush=True)
|
||||
|
|
@ -73,7 +73,7 @@ class Processor(ConsumerProducer):
|
|||
chunks=embeds,
|
||||
)
|
||||
|
||||
self.producer.send(r)
|
||||
await self.send(r)
|
||||
|
||||
except Exception as e:
|
||||
print("Exception:", e, flush=True)
|
||||
|
|
@ -105,5 +105,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Processor(ConsumerProducer):
|
|||
|
||||
self.embeddings = TextEmbedding(model_name = model)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
v = msg.value()
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class Processor(ConsumerProducer):
|
|||
error=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.producer.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -85,5 +85,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Processor(ConsumerProducer):
|
|||
subscriber=module + "-emb",
|
||||
)
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
v = msg.value()
|
||||
print(f"Indexing {v.metadata.id}...", flush=True)
|
||||
|
|
@ -77,7 +77,7 @@ class Processor(ConsumerProducer):
|
|||
entities=entities,
|
||||
)
|
||||
|
||||
self.producer.send(r)
|
||||
await self.send(r)
|
||||
|
||||
except Exception as e:
|
||||
print("Exception:", e, flush=True)
|
||||
|
|
@ -109,5 +109,5 @@ class Processor(ConsumerProducer):
|
|||
|
||||
def run():
|
||||
|
||||
Processor.start(module, __doc__)
|
||||
Processor.launch(module, __doc__)
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Processor(ConsumerProducer):
|
|||
self.client = Client(host=ollama)
|
||||
self.model = model
|
||||
|
||||
def handle(self, msg):
|
||||
async def handle(self, msg):
|
||||
|
||||
v = msg.value()
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class Processor(ConsumerProducer):
|
|||
error=None,
|
||||
)
|
||||
|
||||
self.producer.send(r, properties={"id": id})
|
||||
await self.producer.send(r, properties={"id": id})
|
||||
|
||||
print("Done.", flush=True)
|
||||
|
||||
|
|
@ -93,5 +93,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