def paging(pause=0, marker_property='marker'):
 def wrapper(f):
  def page(*args, **kwargs):
   results = []
   marker = None
   while True:
    try:
     new = f(marker=marker, *args, **kwargs)
     marker = getattr(new, marker_property)
     results.extend(new)
     if (not marker):
      break
     elif pause:
      sleep(pause)
    except TypeError:
     results = f(*args, **kwargs)
     break
   return results
  return page
 return wrapper

def paging ( pause = 0 , marker_property = 'marker' ) : def wrapper ( f ) : def page ( * args , ** kwargs ) : results = [ ] marker = None while True : try : new = f ( marker = marker , * args , ** kwargs ) marker = getattr ( new , marker_property ) results . extend ( new ) if ( not marker ) : break elif pause : sleep ( pause ) except TypeError : results = f ( * args , ** kwargs ) break return results return page return wrapper
adds paging to boto retrieval functions that support a marker this is configurable as not all boto functions seem to use the same name .