Handle Batch Connection Error

While Batch Insertion of data, shows Batch Connection Error due to network error and retries some time . If I try to catch that Exception ,after catched It shows retries. I need to handle Exception after all retries are exhausted how to achieve this.

def insert(class_,obj_count):
vector_val = [[random.random() for _ in range(128)] for _ in range(obj_count)]
start = time.time()

with client.batch as batch: # automatically calls flush()
    for id_, vec in enumerate(vector_val):
        data_obj = {
            "unique_id": id_
            }
        batch.add_data_object(
                data_obj, 
                class_, 
            vector=vec 
            # generate_uuid('Sample',doc), # if not provided, it generates automatically
            )

    print(time.time() - start)
    print(f"Finished importing data for {class_}    Object Count  :{obj_count}")

Hi Dharanish!

Check this for error handling in batch imports:

Tip: If you want to force an error, you can insert an object with 2 dimensions, then a second one with 3 dimensions.

Check this issue here for more on error handling: