作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
详见此处:https://issuetracker.google.com/issues/113672049
在这里交叉发布:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5879 )
在 Python 中从 Google Cloud Functions 使用 Firebase Storage API 时出现连接重置错误。
部署的函数正在调用一个 blob-get,即
from firebase_admin import storage
def fn(request):
bucket = 'my-firebase-bucket'
path = '/thing'
blob = storage.bucket(bucket).get_blob(path)
故障是间歇性的;该功能的成功率约为 90%。
函数部署后第一次调用似乎更容易失败。
最佳答案
云函数是无状态的,但可以重用之前调用的全局状态。这在 tips 中有解释。和 these docs .
使用带重试的全局状态应该会给你一个更强大的功能:
from tenacity import retry, stop_after_attempt, wait_random
from firebase_admin import storage
@retry(stop=stop_after_attempt(3), wait=wait_random(min=1, max=2))
def get_bucket(storage):
return storage.bucket('my-firebase-bucket')
@retry(stop=stop_after_attempt(3), wait=wait_random(min=1, max=2))
def get_blob(bucket, path):
return bucket.get_blob(path)
bucket = get_bucket(storage)
def fn(request):
path = '/thing'
blob = get_blob(bucket, path)
# etc..
关于Python 谷歌云功能连接由同行重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52129628/
在我的 android 应用程序中,我想在同一行中实现 2 个文本字段。如果文本太长可以转到下一行。所以我使用了更精简的水平布局并添加了 2 个文本字段。 [例如:TextView1、TextV
由于node使用了javascript,它可以充当webrtc peer吗? 然后我可以将它编码为 VP8 流并广播给所有其他对等方吗? 最佳答案 WebRTC 是一个浏览器 API 而不是 Java
我是一名优秀的程序员,十分优秀!