def block_until_ready(self, base_url: str):
        """Block until the endpoint is ready."""
        sleep_s = 5
        timeout_s = 5 * 60  # At max, wait 5 minutes

        ping_url = f'{base_url}/ping'

        waited_s = 0
        while True:
            try:
                requests.get(ping_url)
                log.info(f'Endpoint {ping_url} is ready')
                break
            except requests.exceptions.ConnectionError:
                log.debug(
                    f'Endpoint {ping_url} not ready yet. Sleeping {sleep_s} seconds',
                )
                time.sleep(sleep_s)
                waited_s += sleep_s

            if waited_s >= timeout_s:
                raise TimeoutError(
                    f'Endpoint {ping_url} did not become read after {waited_s:,} seconds, exiting',
                )
Block until the endpoint is ready.
llmfoundry/models/inference_api_wrapper/fmapi.py