Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbaea120

Browse files
authored
Merge branch 'main' into release-please--branches--main
2 parentse4bf1e9 +66d84a3 commitbaea120

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

‎google/api_core/bidi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ def _thread_main(self, ready):
664664
_LOGGER.debug("waiting for recv.")
665665
response=self._bidi_rpc.recv()
666666
_LOGGER.debug("recved response.")
667-
self._on_response(response)
667+
ifself._on_responseisnotNone:
668+
self._on_response(response)
668669

669670
exceptexceptions.GoogleAPICallErrorasexc:
670671
_LOGGER.debug(

‎tests/unit/test_bidi.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
importlogging
1717
importqueue
1818
importthreading
19+
importtime
1920

2021
try:
2122
fromunittestimportmock
@@ -894,3 +895,26 @@ def close_side_effect():
894895

895896
# calling stop twice should not result in an error.
896897
consumer.stop()
898+
899+
deftest_stop_error_logs(self,caplog):
900+
"""
901+
Closing the client should result in no internal error logs
902+
903+
https://github.com/googleapis/python-api-core/issues/788
904+
"""
905+
caplog.set_level(logging.DEBUG)
906+
bidi_rpc=mock.create_autospec(bidi.BidiRpc,instance=True)
907+
bidi_rpc.is_active=True
908+
on_response=mock.Mock(spec=["__call__"])
909+
910+
consumer=bidi.BackgroundConsumer(bidi_rpc,on_response)
911+
912+
consumer.start()
913+
consumer.stop()
914+
# let the background thread run for a while before exiting
915+
time.sleep(0.1)
916+
bidi_rpc.is_active=False
917+
# running thread should not result in error logs
918+
error_logs= [r.messageforrincaplog.recordsifr.levelname=="ERROR"]
919+
assertnoterror_logs,f"Found unexpected ERROR logs:{error_logs}"
920+
bidi_rpc.is_active=False

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp