我正在尝试使用UserListService将一些受众(电子邮件/电话匹配)从BigQuery更新为Google广告 我通过每次从查询结果的数据帧中获取1m行块(显然是限制)来将它们分块,但有时连续加载这些块需要很长时间
我一直在试着看看是否可以同时加载一些&;获取一些XML\u STREAM\u EXC错误 我找不到关于这个错误的太多信息,但是由于没有线程,所以我假设它是由于试图一次完成很多事情让API来处理,或者我的代码中出现了一些错误。 这种线程方法可行吗?或者,是否有其他方法可以达到相同的结果(更快的加载)?下面是我得到的,但没有用
# 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()
目前没有回答
相关问题 更多 >
编程相关推荐