def view_aterator(connection, callback, view, view_keys=dict(),
                  args=tuple(), kwargs=dict(), per_page=15,
                  consume_errors=True):
    '''
    Asynchronous iterator for the view. Downloads a view in pages
    and calls the callback for each row.
    This helps avoid transfering data in huge datachunks.
    '''
    skip = 0
    while True:
        keys = dict(view_keys)
        keys.update(dict(skip=skip, limit=per_page))
        records = yield connection.query_view(view, **keys)
        log.debug('view_aterator', "Fetched %d records of the view: %s",
                  len(records), view.name)
        skip += len(records)
        for record in records:
            try:
                yield callback(connection, record, *args, **kwargs)
            except Exception as e:
                error.handle_exception(
                    'view_aterator', e,
                    "Callback %s failed its iteration on a row %r",
                    callback.__name__, record)
                if not consume_errors:
                    raise e

        if not records:
            break
def view_aterator ( connection , callback , view , view_keys = dict ( ) , args = tuple ( ) , kwargs = dict ( ) , per_page = 15 , consume_errors = True ) : skip = 0 while True : keys = dict ( view_keys ) keys . update ( dict ( skip = skip , limit = per_page ) ) records = yield connection . query_view ( view , ** keys ) log . debug ( 'view_aterator' , "Fetched %d records of the view: %s" , len ( records ) , view . name ) skip += len ( records ) for record in records : try : yield callback ( connection , record , * args , ** kwargs ) except Exception as e : error . handle_exception ( 'view_aterator' , e , "Callback %s failed its iteration on a row %r" , callback . __name__ , record ) if not consume_errors : raise e if not records : break
Asynchronous iterator for the view. Downloads a view in pages
    and calls the callback for each row.
    This helps avoid transfering data in huge datachunks.