File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
packages/google-cloud-firestore
google/cloud/firestore_v1 Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -440,6 +440,9 @@ def on_snapshot(self, proto):
440440 proto(`google.cloud.firestore_v1.types.ListenResponse`):
441441 Callback method that receives a object to
442442 """
443+ if self ._closing .locked ():
444+ # don't process on_snapshot responses while spinning down, to prevent deadlock
445+ return
443446 if proto is None :
444447 self .close ()
445448 return
Original file line number Diff line number Diff line change @@ -400,6 +400,15 @@ def test_watch_on_snapshot_target_w_none():
400400 assert inst ._rpc is None
401401
402402
403+ def test_watch_on_snapshot_while_closing ():
404+ inst = _make_watch ()
405+ inst .close = mock .Mock ()
406+ with inst ._closing :
407+ inst .on_snapshot (mock .Mock ())
408+ # close should not be called again when already closing
409+ inst .close .assert_not_called ()
410+
411+
403412def test_watch_on_snapshot_target_no_change_no_target_ids_not_current ():
404413 inst = _make_watch ()
405414 proto = _make_listen_response ()
You can’t perform that action at this time.
0 commit comments