google.api_core.exceptions.ServiceUnavailable: 503 The datastore operation timed out, or the data was temporarily unavailable when using stream

31

def iterate(collection_name, batch_size=5000, cursor=None):
    query = client.collection(collection_name).limit(batch_size).order_by('__name__')
    if cursor:
        query = query.start_after(cursor)

    for doc in query.stream():
        yield doc
    
    if 'doc' in locals():
        yield from iterate(collection_name, batch_size, doc)

Comments

Submit
0 Comments