在使用 Google App Engine (Python) 读取大量数据时,我们需要将数据重新打包并存储到 App Engine 数据存储中。对于一个大型帐户,可能会包含大约 50,000 个条目。每次从 API 获取一些条目时,我们都会将 500 个条目作为一批存储在临时表中,然后将处理任务发送到队列。为了防止在一个队列中塞入太多任务,我们总共使用了 6 个队列:
count = 0
worker_number = 6
for folder, property in entries:
data[count] = {
# repackaging data here
}
count = (count + 1) % 500
if count == 0:
cache = ClientCache(parent=user_key, data=json.d