无法使用Boto对EMR集群进行分页

无法使用Boto对EMR集群进行分页

本文介绍了无法使用Boto对EMR集群进行分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我大约有55个EMR集群(它们都已终止),并且一直在尝试使用 boto 中的 list_clusters 方法检索整个55个EMR集群.我一直在寻找有关从boto分页结果集数量的示例,但找不到任何示例.鉴于此声明:

I have about 55 EMR clusters (all of them were terminated) and have been trying to retrieve the entire 55 EMR clusters using the list_clusters method in boto. I've been searching for examples about paginating the number of result set from boto but couldn't find any examples. Given this statement:

emr_object.list_clusters(cluster_states=["TERMINATED"], marker="what_should_i_use_here").clusters

我不断收到 InvalidRequestException 错误:

boto.exception.EmrResponseError: EmrResponseError: 400 Bad Request
<ErrorResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
  <Error>
    <Type>Sender</Type>
    <Code>InvalidRequestException</Code>
    <Message>Marker 'what_should_i_use_here' is not valid.</Message>
  </Error>
  <RequestId>555b91bd-c122-11e3-8e31-abc75abdb39d</RequestId>
</ErrorResponse>

我应该在 marker 参数中提供什么,以便我可以正确地对查询进行分页?

What should I provide in marker param so that I can properly paginate the query?

谢谢!

推荐答案

您可以在第一轮通过无"操作.

You can pass in None the first time round.

如果返回的ClusterListResult具有marker属性,则可以稍后再传递该属性,例如

If the ClusterListResult you get back has a marker attribute then you can pass that in later, e.g.

m=None
while True:
    try:
        cluster_list_result=emr_object.describe_jobflows(states=['TERMINATED'], marker=m)
        .... Do whatever with cluster_list_result.clusters
        m=cluster_list_result.marker  # See if there are more
    except AttributeError:
        break

这篇关于无法使用Boto对EMR集群进行分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 05:38