Provider cleanup

This commit is contained in:
Zoe Roux 2025-05-16 12:57:31 +02:00
parent 418edb6c85
commit a3ae9fb64e
No known key found for this signature in database
2 changed files with 8 additions and 5 deletions

View File

@ -31,8 +31,9 @@ async def lifespan(_):
if is_master:
await migrate();
# creating the processor makes it listen to requests event in pg
provider = tmdb #CompositeProvider(tmdb)
async with (
RequestProcessor(db, client, CompositeProvider(tmdb)) as processor,
RequestProcessor(db, client, provider) as processor,
get_db() as db,
):
_ = asyncio.create_task(processor.process_all())

View File

@ -8,8 +8,8 @@ from asyncpg import Connection
from pydantic import Field, TypeAdapter
from .client import KyooClient
from .models.videos import Guess, Resource, Video
from .providers.composite import CompositeProvider
from .models.videos import Guess, Resource
from .providers.provider import Provider
from .utils import Model
logger = getLogger(__name__)
@ -54,7 +54,7 @@ class RequestProcessor:
self,
database: Connection,
client: KyooClient,
providers: CompositeProvider,
providers: Provider,
):
self._database = database
self._client = client
@ -79,7 +79,9 @@ class RequestProcessor:
try:
found = await self.process_request()
except Exception as e:
logger.error("Failed to process one of the metadata request", exc_info=e)
logger.error(
"Failed to process one of the metadata request", exc_info=e
)
async def process_request(self):
cur = await self._database.fetchrow(