def METHOD_NAME(client, jobflow_id):
  """Waiting for a new cluster to be ready."""
  while True:
    response = client.describe_cluster(ClusterId=jobflow_id)
    cluster_status = response['Cluster']['Status']
    state = cluster_status['State']
    if 'Message' in cluster_status['StateChangeReason']:
      state = cluster_status['State']
      message = cluster_status['StateChangeReason']['Message']
      if state in ['TERMINATED', 'TERMINATED', 'TERMINATED_WITH_ERRORS']:
        raise Exception(message)
      if state == 'WAITING':
        print('EMR cluster create completed')
        break
    print("Cluster state: {}, wait 15s for cluster to start up.".format(state))
    time.sleep(15)