google.api_core.exceptions.ServiceUnavailable:503数据存储区操作超时,或者使用流时数据暂时不可用

时间:2019-07-01 20:45:55

标签: python google-cloud-firestore

我正在尝试遍历Firestore中的所有文档。我在Python中运行以下代码

from google.cloud.firestore import Client

client = Client()

docs = list()
for es in client.collection('exchange-statements').stream():
    docs.append(es)

但是会产生以下错误

google.api_core.exceptions.ServiceUnavailable: 503 The datastore operation timed out, or the data was temporarily unavailable.

我正在使用google-cloud-firestore v1.2.0

编辑

由于我的问题是关于流送文档而不仅仅是计数,所以它与找到的解决方案here不同。

1 个答案:

答案 0 :(得分:0)

answer here的启发,我想到了一个通用解决方案。但是,我想知道是否还有更好的解决方案。

{
    "Time":[
        {
            "Description":"Shoution app",
            "Total":"240",
            "In_Location":"507, 1st Main Road,Murugeshpalya,Bengaluru,Karnataka,India,560017",
            "In":"01:49:07",
            "Out":"01:49:24",
            "Out_Location":"487, 1st Main Road,Murugeshpalya,Bengaluru,Karnataka,India,560017"
        }
    ],
    "Employee_ID":"160",
    "Date":"2019-07-02"
}