# here's what we're going to do to each chunk
def google_stuff(chunkStart,chunkEnd):
add_to_audience = gAudienceService.mutateMembers([{'operand': {'userListId': this_audience_id,'membersList': [json.loads(x) for x in add_query_data[chunkStart:chunkEnd].to_dict(orient='list')['GOOGLE']]},'operator': 'ADD'}])
# Chunk up the volume
chunkStart = 0
chunkIncrement = 1000000
chunkEnd = chunkStart+chunkIncrement
threads = []
counter = 0
# make some threads
while True:
if add_len > 0 and chunkStart < add_len:
this_thread_name = 'add_users_'+str(counter)
this_thread = threading.Thread(name=this_thread_name, target=google_stuff, args=(chunkStart,chunkEnd,))
threads.append(this_thread)
this_thread.start()
time.sleep(5)
chunkStart += chunkIncrement
chunkEnd += chunkIncrement
counter += 1
else:
break
# wait till they all finish
for t in threads:
t.join()