[Python] Can i update lifespan in fastapi without restarting the app

Discussão em 'Python' iniciado por Stack, Maio 21, 2025.

  1. Stack

    Stack Membro Participativo

    I want to update values in lifespan of fastapi. This is the code

    @asynccontextmanager
    async def lifespan(app: FastAPI):
    names = requests.get(url).json()
    yield


    Let say i knew that the response of API has been updated. Is there a way I can update the value name in lifespan without stopping and starting the app.

    May be just creating another endpoint, upon calling the value of names in lifespan event got override. Thanks

    Continue reading...

Compartilhe esta Página