Loading audiences via Adwords api/python SDK

35 views
Skip to first unread message

Stephen Waters

unread,
Oct 3, 2019, 3:51:20 AM10/3/19
to AdWords API and Google Ads API Forum
Hi

I am trying to update some audiences (email/phone matches) from BigQuery to Google Ads
The largest are in the millions of rows, but less than 10 million for now
I am chunking them up to 1m row chunks but sometimes loading these consecutively takes a long time.

I have been dabbling with threading, trying to load different chunks of an audience concurrently & getting some XML_STREAM_EXC errors
I couldn't find much about this error but as things work without threading, I assume it's driven by trying to do much at once for the API to handle, or some mistake in the code on my part.
Is this threaded approach possible? Or is there another way to get to the same result (faster loads)? Below is what I got to, which didn't work.

Thanks

Stephen

# 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()

Google Ads API Forum Advisor Prod

unread,
Oct 3, 2019, 4:47:27 AM10/3/19
to adwor...@googlegroups.com
Hi Stephen,

Thank you for reaching out.

However, it appears that the issue you are encountering is more related to the Python client library. That said, I would recommend that you reach out directly to the client library owners via this link as they are better equipped to assist you regarding this matter.

I hope this helps.

Best regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UKM14S:ref
Reply all
Reply to author
Forward
0 new messages