Auto-update: Tue Jul 30 11:55:46 PDT 2024
This commit is contained in:
parent
6018a025df
commit
f379a2ec9d
1 changed files with 6 additions and 7 deletions
|
@ -204,15 +204,14 @@ class APIConfig(BaseModel):
|
||||||
TZ: str
|
TZ: str
|
||||||
KEYS: List[str]
|
KEYS: List[str]
|
||||||
GARBAGE: Dict[str, Any]
|
GARBAGE: Dict[str, Any]
|
||||||
db_pool: Optional[DatabasePool] = Field(default=None, exclude=True)
|
|
||||||
|
|
||||||
def __init__(self, **data):
|
def __init__(self, **data):
|
||||||
super().__init__(**data)
|
super().__init__(**data)
|
||||||
self.db_pool = DatabasePool()
|
self._db_pool = DatabasePool()
|
||||||
|
|
||||||
@validator('db_pool', pre=True, always=True)
|
@property
|
||||||
def set_db_pool(cls, v):
|
def db_pool(self):
|
||||||
return v or DatabasePool()
|
return self._db_pool
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, config_path: Union[str, Path], secrets_path: Union[str, Path]):
|
def load(cls, config_path: Union[str, Path], secrets_path: Union[str, Path]):
|
||||||
|
@ -722,8 +721,8 @@ class APIConfig(BaseModel):
|
||||||
return exists
|
return exists
|
||||||
|
|
||||||
async def close_db_pools(self):
|
async def close_db_pools(self):
|
||||||
if self.db_pool:
|
if self._db_pool:
|
||||||
await self.db_pool.close_all()
|
await self._db_pool.close_all()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue