You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python脚本连接Firestore数据库时偶发冻结并超时的问题排查求助

Python脚本连接Firestore数据库时偶发冻结并超时的问题排查求助

大家好,我写了个简单的Python脚本用来从Google Firestore数据库获取数据,大部分时候运行都正常,但偶尔会直接卡住,过一会儿就抛出超时错误。我想请教下可能的原因是什么,以及该怎么排查调试这个问题?

我的脚本代码如下:

import firebase_admin
from firebase_admin import firestore

app = firebase_admin.initialize_app()
db = firestore.client()

def get_name(room: str) -> str:
    '''Returns the name of given room resident'''
    room_ref = db.collection('users').document(room)
    name = room_ref.get().to_dict()['residentName']
    return name

print(get_name('A101'))

出现超时的时候,会抛出下面的错误:

raise exceptions.RetryError(
google.api_core.exceptions.RetryError: Deadline of 300.0s exceeded while calling target function, last exception: 504 Deadline Exceeded

我已经查过Firestore的官方文档了,但没找到针对这个简单项目的具体限制说明,实在摸不着头绪,希望能得到大家的指点!

备注:内容来源于stack exchange,提问作者Kons

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 12:54:36