mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-18 01:31:02 +02:00
Migrate api-gateway to async
This commit is contained in:
parent
24d05cbcdf
commit
8b24fa4209
13 changed files with 37 additions and 56 deletions
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
from pulsar.schema import JsonSchema
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
import pulsar
|
||||
|
|
@ -16,7 +18,6 @@ class Publisher:
|
|||
|
||||
async def start(self):
|
||||
self.task = asyncio.create_task(self.run())
|
||||
await self.task.start()
|
||||
|
||||
async def stop(self):
|
||||
self.running = False
|
||||
|
|
@ -32,14 +33,14 @@ class Publisher:
|
|||
try:
|
||||
producer = self.client.create_producer(
|
||||
topic=self.topic,
|
||||
schema=self.schema,
|
||||
schema=JsonSchema(self.schema),
|
||||
chunking_enabled=self.chunking_enabled,
|
||||
)
|
||||
|
||||
while self.running:
|
||||
|
||||
try:
|
||||
id, item = asyncio.wait_for(
|
||||
id, item = await asyncio.wait_for(
|
||||
self.q.get(),
|
||||
timeout=0.5
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue