Skip to content

Commit c56902c

Browse files
authored
Merge branch 'main' into add-protobuf-runtime-header
2 parents ce92a34 + 66d84a3 commit c56902c

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:5581906b957284864632cde4e9c51d1cc66b0094990b27e689132fe5cd036046
17-
# created: 2025-03-04
16+
digest: sha256:a7aef70df5f13313ddc027409fc8f3151422ec2a57ac8730fce8fa75c060d5bb
17+
# created: 2025-04-10T17:00:10.042601326Z

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+
if self._on_response is not None:
668+
self._on_response(response)
668669

669670
except exceptions.GoogleAPICallError as exc:
670671
_LOGGER.debug(

owlbot.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
excludes = [
2727
"noxfile.py", # pytype
2828
"setup.cfg", # pytype
29-
".flake8", # flake8-import-order, layout
3029
".coveragerc", # layout
3130
"CONTRIBUTING.rst", # no systests
3231
".github/workflows/unittest.yml", # exclude unittest gh action
@@ -36,18 +35,6 @@
3635
templated_files = common.py_library(microgenerator=True, cov_level=100)
3736
s.move(templated_files, excludes=excludes)
3837

39-
# Add pytype support
40-
s.replace(
41-
".gitignore",
42-
"""\
43-
.pytest_cache
44-
""",
45-
"""\
46-
.pytest_cache
47-
.pytype
48-
""",
49-
)
50-
5138
python.configure_previous_major_version_branches()
5239

5340
s.shell.run(["nox", "-s", "blacken"], hide_output=False)

tests/unit/test_bidi.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import logging
1717
import queue
1818
import threading
19+
import time
1920

2021
try:
2122
from unittest import mock
@@ -894,3 +895,26 @@ def close_side_effect():
894895

895896
# calling stop twice should not result in an error.
896897
consumer.stop()
898+
899+
def test_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.message for r in caplog.records if r.levelname == "ERROR"]
919+
assert not error_logs, f"Found unexpected ERROR logs: {error_logs}"
920+
bidi_rpc.is_active = False

0 commit comments

Comments
 (0)