from contextlib import asynccontextmanager from fastapi import FastAPI from app import api_router from utils.scripts import pools_creator, pools_destroy, db_startup @asynccontextmanager async def lifespan(app: FastAPI): await pools_creator() yield await pools_destroy() app = FastAPI(lifespan=lifespan) app.include_router(router=api_router)