Hey @ab1,
You don’t need to store the results really, just calling .result() on them would be fine in knowing if there’s an error.
May I suggest you another approach to make the upserts faster? Instead of using async, you can try using multiple instances of the client. You can create a multiprocessing pool in python and have each of them perform upserts independently. This would be faster. However, if you don’t have enough pods on your index, this may cause some timeouts as the index won’t be able to keep up, hence we have to be a little conservative with the number of processes.
Here’s an example:
import multiprocessing
import os
import pinecone
import uuid
import numpy as np
def upsert(data,index_name,batch):
key = 'API_KEY'
pinecone.init(api_key=key,environment='ENV')
index = pinecone.GRPCIndex(index_name)
index.describe_index_stats()
def chunker(sqd,size):
return (seq[pos:pos + size] for pos in range(0, len(seq), size))
for chunk in chunker(data,batch):
index.upsert(vectors=chunk)
if __name__=="__main__":
mgr = multiprocessing.Manager()
num_processes = 6
for i in range(num_processes):
multiprocessing.Process(target=upsert,args=(data,index_name,batch_size)