当我想使用Boto 3获取EMR列表时无法获得
我尝试了不同的方式
m="None"
while True:
try:
cluster_list_result=client.list_clusters(ClusterStates=['WAITING'], CreatedAfter=datetime(2017,5,19),
CreatedBefore=datetime(2019,5,19) ,Marker=m)
print(cluster_list_result)
m=cluster_list_result.Marker # See if there are more
print("m value is" +m)
except AttributeError:
break
需要cliuster detils的列表
答案 0 :(得分:1)
boto3-emr的list_client api不希望Marker参数为None。同样,不必总是将Marker参数作为响应返回,因为它只是用于进一步结果的分页令牌。
我已经对您的代码进行了一些更新,对我来说效果很好:
import boto3
client = boto3.client('emr',region_name='us-east-1')
marker=None
while True:
try:
if marker:
cluster_list_result=client.list_clusters(ClusterStates=['WAITING'], CreatedAfter=datetime(2017,5,19), CreatedBefore=datetime(2019,5,19), Marker=marker)
else:
cluster_list_result = client.list_clusters(ClusterStates=['WAITING'], CreatedAfter=datetime(2017, 5, 19), CreatedBefore=datetime(2019, 5, 19))
print cluster_list_result
if 'Marker' in cluster_list_result:
marker = cluster_list_result['Marker']
else:
break
except Exception, e:
raise e