def get_entity(self, item_id):
    if (item_id in self.entity_cache):
        return self.entity_cache[item_id]
    while True:
        try:
            entity = get_entity_dict_from_api(item_id)
            self.entity_cache[item_id] = entity
            self.save_entity_cache()
            return entity
        except (ConnectionError, MaxRetryError) as e:
            time.sleep(1)
            continue
        except LdiResponseNotOk:
            self.entity_cache[item_id] = 'deleted'
            self.save_entity_cache()
            return 'deleted'
def get_entity(self, item_id):
    if (item_id in self.entity_cache):
        return self.entity_cache[item_id]
    while True:
        try:
            entity = get_entity_dict_from_api(item_id)
            self.entity_cache[item_id] = entity
            self.save_entity_cache()
            return entity
        except (ConnectionError, MaxRetryError) as e:
            time.sleep(1)
            continue
        except LdiResponseNotOk:
            self.entity_cache[item_id] = 'deleted'
            self.save_entity_cache()
            return 'deleted'