Skip to content

Commit c18475c

Browse files
committed
move stop call to within the exception clauses
1 parent bf74b4a commit c18475c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

google/api_core/bidi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,16 @@ def _thread_main(self, ready):
676676
exc,
677677
exc_info=True,
678678
)
679+
self.stop()
679680

680681
except Exception as exc:
681682
_LOGGER.exception(
682683
"%s caught unexpected exception %s and will exit.",
683684
_BIDIRECTIONAL_CONSUMER_NAME,
684685
exc,
685686
)
687+
self.stop()
686688

687-
self.stop()
688689
_LOGGER.info("%s exiting", _BIDIRECTIONAL_CONSUMER_NAME)
689690

690691
def start(self):

tests/unit/test_bidi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ def test_fatal_exceptions_will_shutdown_consumer(self, caplog):
926926
lead to the consumer halting should also stop the thread and rpc.
927927
"""
928928
caplog.set_level(logging.DEBUG)
929-
bidi_rpc = mock.create_autospec(bidi.BidiRpc, instance=True)
929+
bidi_rpc = mock.create_autospec(bidi.ResumableBidiRpc, instance=True)
930930
bidi_rpc.is_active = True
931931
on_response = mock.Mock(spec=["__call__"])
932932

0 commit comments

Comments
 (0)