From 2f1384bc23c380c81bdd79bb559fc4cbcae00345 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Tue, 30 Jul 2024 11:55:46 -0700 Subject: [PATCH] Auto-update: Tue Jul 30 11:55:46 PDT 2024 --- sijapi/classes.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sijapi/classes.py b/sijapi/classes.py index 1301acb..71f2f7d 100644 --- a/sijapi/classes.py +++ b/sijapi/classes.py @@ -204,15 +204,14 @@ class APIConfig(BaseModel): TZ: str KEYS: List[str] GARBAGE: Dict[str, Any] - db_pool: Optional[DatabasePool] = Field(default=None, exclude=True) def __init__(self, **data): super().__init__(**data) - self.db_pool = DatabasePool() + self._db_pool = DatabasePool() - @validator('db_pool', pre=True, always=True) - def set_db_pool(cls, v): - return v or DatabasePool() + @property + def db_pool(self): + return self._db_pool @classmethod def load(cls, config_path: Union[str, Path], secrets_path: Union[str, Path]): @@ -722,8 +721,8 @@ class APIConfig(BaseModel): return exists async def close_db_pools(self): - if self.db_pool: - await self.db_pool.close_all() + if self._db_pool: + await self._db_pool.close_all()