def make_session_context() -> Callable[[], ContextManager[Session]]:
    """A functional closure that will store engine
        Call it n times if you want to n connection pools

    Returns:
        Callable[[], Callable[[], ContextManager[Session]]]
            a function that return a contextmanager


    Examples:
        # First initialize a connection pool,
        # when you want to a new connetion pool
        session_context = make_session_context()
        ...
        # You use it multiple times as follows.
        with session_context() as session:
            session.query(SomeMapperClass).filter_by(id=1).one()
    """
    engine = None

    def wrapper_get_session():
        nonlocal engine
        if engine is None:
            engine = get_engine(get_database_uri())
        return get_session(engine)

    return wrapper_get_session
A functional closure that will store engine
        Call it n times if you want to n connection pools

    Returns:
        Callable[[], Callable[[], ContextManager[Session]]]
            a function that return a contextmanager


    Examples:
        # First initialize a connection pool,
        # when you want to a new connetion pool
        session_context = make_session_context()
        ...
        # You use it multiple times as follows.
        with session_context() as session:
            session.query(SomeMapperClass).filter_by(id=1).one()
    
web_console_v2/api/fedlearner_webconsole/db.py