def safe_get_info(ee_object, max_num_attempts=5):
    '''Keep trying to call getInfo() on an Earth Engine object until it succeeds.'''
    
    # Do not try again if we get one of these exceptions
    fail_messages = ['Too many pixels']
    
    num_attempts = 0
    while True:
        try:
            return ee_object.getInfo()
        except Exception as e:
            # Rethrow the exception if it is not timeout related
            for message in fail_messages:
                if message in str(e):
                    raise e
                    
            print 'Earth Engine Error: %s. Waiting 10s and then retrying.' % (e)
            time.sleep(10)
            num_attempts += 1
        if max_num_attempts and (num_attempts >= max_num_attempts):
            raise Exception('safe_get_info failed to succeed after ' +str(num_attempts)+ ' attempts!')
dataset/ETHPy150Open nasa/CrisisMappingToolkit/cmt/util/miscUtilities.py/safe_get_info/original