code: def _await_server_up_or_die(port, timeout=30):
      """Waits until the local flask server is listening on the given port."""
      _logger.info(f"Awaiting server to be up on {LOCALHOST}:{port}")
      start_time = time.time()
      while time.time() - start_time < timeout:
          with socket.socket(
              socket.AF_INET, socket.SOCK_STREAM
          ) as sock:
              sock.settimeout(2)
              if sock.connect_ex((LOCALHOST, port)) == 0:
                  _logger.info(f"Server is up on {LOCALHOST}:{port}!")
                  break
          _logger.info("Server not yet up, waiting...")
          time.sleep(0.5)
      else:
          raise Exception(
              f"Failed to connect on {LOCALHOST}:{port} within {timeout} seconds"
          )
  
file_path: mlflow/tests/tracking/integration_test_utils.py
imports: import contextlib
  import logging
  import os
  import socket
  import sys
  import time
  from subprocess import Popen
  import mlflow
  from mlflow.server import ARTIFACT_ROOT_ENV_VAR, BACKEND_STORE_URI_ENV_VAR
  from tests.helper_functions import LOCALHOST, get_safe_port
label_desc: Use image node_id 1 for calling a global function with example usage: _await_server_up_or_die(port, timeout) without return types