【发布时间】:2020-05-14 01:13:53
【问题描述】:
我有一个应用程序使用 google-cloud-firestore 监听来自 Firestore 集合的更新。对于每次更新,我都需要将一些数据上传到需要时间的 FTP 服务器。同时接收大量数据会引入不可接受的延迟,我认为答案是异步回调(即在继续之前不要等待我的回调结束),但这是可能的。
想象一下这样的脚本
from google.cloud.firestore import Client
import time
def callback(col_snapshot, changes, read_time):
print("Received updates")
# mock FTP upload
time.sleep(1)
print("Finished handling the updates")
Client().collection('news').on_snapshot(callback)
while True:
pass
如何修改该代码,使其不会对每个回调进行排队。
更新
我在google-cloud-firestore创建了一个功能请求
【问题讨论】:
标签: python google-cloud-firestore ftp python-asyncio