Skip to content

Commit 56b7e98

Browse files
committed
fix: harden the wait for consistency for firestore multiple listen snippet
1 parent 46e1d16 commit 56b7e98

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

firestore/cloud-client/snippets.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,13 @@ def on_snapshot(col_snapshot, changes, read_time):
702702
u'population': 860000
703703
}
704704
db.collection(u'cities').document(u'SF').set(data)
705-
sleep(1)
705+
706+
# Wait for 'SF' to be in the doc_map for up to 60 seconds.
707+
waited = 0
708+
while waited < 60 and not [x for x in query_watch.doc_map.keys() if x.endswith('/SF')]:
709+
waited += 1
710+
sleep(1)
711+
706712
query_watch.unsubscribe()
707713

708714

0 commit comments

Comments
 (0)