parameters: (
      host: str,
      port: int,
      emulator: AbstractEmulator,
      retries: int = 3,
      interval_seconds: float = 0.1,
  )
docstring: Run an emulator as a client.
  
      Args:
          host: Host to connect to.
          port: Port to connect on.
          emulator: The emulator instance.
          retries: Number of retries on a failed connection attempt.
          interval_seconds: How long to wait between retries.
  
      Returns:
          None
docstring_summary: Run an emulator as a client.
docstring_tokens: Run an emulator as a client .
function: async def run_emulator_client(
      host: str,
      port: int,
      emulator: AbstractEmulator,
      retries: int = 3,
      interval_seconds: float = 0.1,
  ) -> None:
      """Run an emulator as a client.
  
      Args:
          host: Host to connect to.
          port: Port to connect on.
          emulator: The emulator instance.
          retries: Number of retries on a failed connection attempt.
          interval_seconds: How long to wait between retries.
  
      Returns:
          None
      """
      log.info(f"Connecting to {emulator.__class__.__name__} at {host}:{port}")
  
      r: Optional[asyncio.StreamReader] = None
      w: Optional[asyncio.StreamWriter] = None
      for i in range(retries):
          try:
              r, w = await asyncio.open_connection(host, port)
              break
          except IOError:
              log.error(
                  f"{emulator.__class__.__name__} failed to connect on "
                  f"try {i + 1}. Retrying in {interval_seconds} seconds."
              )
              await asyncio.sleep(interval_seconds)
  
      if r is None or w is None:
          raise IOError(
              f"Failed to connect to {emulator.__class__.__name__} at "
              f"{host}:{port} after {retries} retries."
          )
  
      connection = ConnectionHandler(emulator)
      await connection(r, w)
function_tokens: async def run_emulator_client ( host : str , port : int , emulator : AbstractEmulator , retries : int = 3 , interval_seconds : float = 0.1 , ) -> None : log . info ( f"Connecting to {emulator.__class__.__name__} at {host}:{port}" ) r : Optional [ asyncio . StreamReader ] = None w : Optional [ asyncio . StreamWriter ] = None for i in range ( retries ) : try : r , w = await asyncio . open_connection ( host , port ) break except IOError : log . error ( f"{emulator.__class__.__name__} failed to connect on " f"try {i + 1}. Retrying in {interval_seconds} seconds." ) await asyncio . sleep ( interval_seconds ) if r is None or w is None : raise IOError ( f"Failed to connect to {emulator.__class__.__name__} at " f"{host}:{port} after {retries} retries." ) connection = ConnectionHandler ( emulator ) await connection ( r , w )