def METHOD_NAME(self) -> Session:
    if self.__closed:
        raise ConnectionError("SessionPool has already been closed.")
    should_create = False
    start = time.time()
    session = self.__poll_session()
    while session is None:
        with self.__lock:
            if self.__pool_size < self.__max_pool_size:
                self.__pool_size += 1
                should_create = True
                break
            else:
                if time.time() - start > self.__wait_timeout_in_ms:
                    raise TimeoutError(
                        "Wait to get session timeout in SessionPool, current pool size: {0}".format(
                            self.__max_pool_size
                        )
                    )
                time.sleep(1)
        session = self.__poll_session()
    if should_create:
        try:
            session = self.__construct_session()
        except Exception as e:
            with self.__lock:
                self.__pool_size -= 1
            raise e
    return session