order and api and more

This commit is contained in:
2025-04-17 00:09:16 -04:00
parent 593e8960b7
commit 21408af48c
31 changed files with 1924 additions and 542 deletions

View File

@ -1,7 +1,6 @@
from typing import Any, Dict, Optional, Union
import aiohttp
import logging
from app.services.service_registry import ServiceRegistry
import json
logger = logging.getLogger(__name__)
@ -11,8 +10,6 @@ class BaseExternalService:
self.base_url = base_url
self.api_key = api_key
self.session = None
# Register the service instance
ServiceRegistry.register(self.__class__.__name__, self)
async def _get_session(self) -> aiohttp.ClientSession:
if self.session is None or self.session.closed:
@ -72,5 +69,8 @@ class BaseExternalService:
raise
async def close(self):
"""Close the aiohttp session if it exists"""
if self.session and not self.session.closed:
await self.session.close()
await self.session.close()
self.session = None
logger.info(f"Closed session for {self.__class__.__name__}")