def get_ip(self):
    s3_client = self.get_client()
    time_elapsed = 0
    try:
        while (time_elapsed < SAGEMAKER_WAIT_TIME):
            response = s3_client.list_objects(Bucket=self.bucket, Prefix=self.done_file_key)
            if ('Contents' in response):
                break
            time.sleep(1)
            time_elapsed += 1
            if ((time_elapsed % 5) == 0):
                LOG.info('Waiting for SageMaker Redis server IP: Time elapsed: %s seconds', time_elapsed)
        if (time_elapsed >= SAGEMAKER_WAIT_TIME):
            log_and_exit('Timed out while attempting to retrieve the Redis IP', SIMAPP_S3_DATA_STORE_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_500)
        s3_client.download_file(self.bucket, self.config_key, 'ip.json')
        with open('ip.json') as file:
            ip_file = json.load(file)['IP']
        return ip_file
    except botocore.exceptions.ClientError:
        log_and_exit('Unable to retrieve redis ip', SIMAPP_S3_DATA_STORE_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_400)
    except Exception:
        log_and_exit('Unable to retrieve redis ip', SIMAPP_S3_DATA_STORE_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_500)
def get_ip(self):
    s3_client = self.get_client()
    time_elapsed = 0
    try:
        while (time_elapsed < SAGEMAKER_WAIT_TIME):
            response = s3_client.list_objects(Bucket=self.bucket, Prefix=self.done_file_key)
            if ('Contents' in response):
                break
            time.sleep(1)
            time_elapsed += 1
            if ((time_elapsed % 5) == 0):
                LOG.info('Waiting for SageMaker Redis server IP: Time elapsed: %s seconds', time_elapsed)
        if (time_elapsed >= SAGEMAKER_WAIT_TIME):
            log_and_exit('Timed out while attempting to retrieve the Redis IP', SIMAPP_S3_DATA_STORE_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_500)
        s3_client.download_file(self.bucket, self.config_key, 'ip.json')
        with open('ip.json') as file:
            ip_file = json.load(file)['IP']
        return ip_file
    except botocore.exceptions.ClientError:
        log_and_exit('Unable to retrieve redis ip', SIMAPP_S3_DATA_STORE_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_400)
    except Exception:
        log_and_exit('Unable to retrieve redis ip', SIMAPP_S3_DATA_STORE_EXCEPTION, SIMAPP_EVENT_ERROR_CODE_500)