Title: Regression in v2.13.0: ConsumeBidirectionalStream caught unexpected exception and will exit · Issue #560 · googleapis/python-api-core · GitHub
Open Graph Title: Regression in v2.13.0: ConsumeBidirectionalStream caught unexpected exception and will exit · Issue #560 · googleapis/python-api-core
X Title: Regression in v2.13.0: ConsumeBidirectionalStream caught unexpected exception and will exit · Issue #560 · googleapis/python-api-core
Description: tl;dr: Cause and fix I believe v2.13.0 introduced a regression here: v2.12.0...v2.13.0#diff-769a9f2c04700ff355d77a3292b7ff3cea5ff9bda91d0b31138eeb89fcd4d02dL95-L98 v2.12.0 code: def _is_active(self): # Note: there is a possibility that t...
Open Graph Description: tl;dr: Cause and fix I believe v2.13.0 introduced a regression here: v2.12.0...v2.13.0#diff-769a9f2c04700ff355d77a3292b7ff3cea5ff9bda91d0b31138eeb89fcd4d02dL95-L98 v2.12.0 code: def _is_active(self...
X Description: tl;dr: Cause and fix I believe v2.13.0 introduced a regression here: v2.12.0...v2.13.0#diff-769a9f2c04700ff355d77a3292b7ff3cea5ff9bda91d0b31138eeb89fcd4d02dL95-L98 v2.12.0 code: def _is_active(self...
Opengraph URL: https://github.com/googleapis/python-api-core/issues/560
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression in v2.13.0: ConsumeBidirectionalStream caught unexpected exception and will exit","articleBody":"#### tl;dr: Cause and fix\r\n\r\nI believe v2.13.0 introduced a regression here: https://github.com/googleapis/python-api-core/compare/v2.12.0...v2.13.0#diff-769a9f2c04700ff355d77a3292b7ff3cea5ff9bda91d0b31138eeb89fcd4d02dL95-L98\r\n\r\nv2.12.0 code:\r\n```\r\n def _is_active(self):\r\n # Note: there is a possibility that this starts *before* the call\r\n # property is set. So we have to check if self.call is set before\r\n # seeing if it's active.\r\n if self.call is not None and not self.call.is_active():\r\n return False\r\n else:\r\n return True\r\n```\r\n\r\nv2.13.0 code:\r\n\r\n```\r\n def _is_active(self):\r\n # Note: there is a possibility that this starts *before* the call\r\n # property is set. So we have to check if self.call is set before\r\n # seeing if it's active.\r\n return self.call is not None and self.call.is_active()\r\n```\r\n\r\nNote that in `v2.12.0` version `_is_active()` will return True when `self.call is None` but in `v2.13.0` this will return False.\r\n\r\nThis seems to very directly violate the behaviour highlighted in the comment:\r\n\r\n```\r\n # Note: there is a possibility that this starts *before* the call\r\n # property is set. So we have to check if self.call is set before\r\n # seeing if it's active.\r\n```\r\n\r\nAs such the fix should be as simple as\r\n\r\n```\r\nreturn self.call is None or self.call.is_active()\r\n```\r\n\r\n#### Environment details\r\n\r\n - OS type and version: Mac 14.1.1 \r\n - Python version: `python --version`: 3.9.18\r\n - pip version: `pip --version`: 22.3\r\n - `google-api-core` version: `pip show google-api-core`\r\n\r\n```\r\nName: google-api-core\r\nVersion: 2.14.0\r\nSummary: Google API client core library\r\nHome-page: https://github.com/googleapis/python-api-core\r\nAuthor: Google LLC\r\nAuthor-email: googleapis-packages@google.com\r\nLicense: Apache 2.0\r\nLocation: /Users/dhendry/code/perpetua-pybackend-common/.venv/lib/python3.9/site-packages\r\nRequires: google-auth, googleapis-common-protos, protobuf, requests\r\nRequired-by: firebase-admin, google-api-python-client, google-cloud-appengine-logging, google-cloud-bigquery, google-cloud-bigquery-storage, google-cloud-core, google-cloud-firestore, google-cloud-logging, google-cloud-pubsub, google-cloud-secret-manager, google-cloud-storage, google-cloud-tasks\r\n```\r\n\r\nAlso relevant here: \r\n\r\n```\r\nName: google-cloud-bigquery-storage\r\nVersion: 2.22.0\r\nSummary: Google Cloud Bigquery Storage API client library\r\nHome-page: https://github.com/googleapis/python-bigquery-storage\r\nAuthor: Google LLC\r\nAuthor-email: googleapis-packages@google.com\r\nLicense: Apache 2.0\r\nLocation: /Users/dhendry/code/perpetua-pybackend-common/.venv/lib/python3.9/site-packages\r\nRequires: google-api-core, proto-plus, protobuf\r\nRequired-by: perpetua-pybackend-common\r\n```\r\n\r\n#### Steps to reproduce\r\n\r\nAfter upgrading `google-api-core` from `2.12.0` to `2.13.0` we are seeing an `ConsumeBidirectionalStream caught unexpected exception and will exit.` error when using the `BigQueryWriteClient`. I have narrowed down the issue to this library, NOT the google-cloud-bigquery-storage library\r\n\r\nNote: you many need to be on a slow-ish network connection (\u003c= ~50 MBit/sec) to reproduce reliably.\r\n\r\n 1. Create an `AppendRowsStream`\r\n 2. Call `.send()` with a large `AppendRowsRequest` request (close to the maximum, say 9 MB). Very specifically, it seems that the request must be large enough to take more than 1 second to complete (1 second because that is the default value for `google.api_core.bidi._RequestQueueGenerator._period`)\r\n 3. An exception will be raised\r\n\r\n#### Code example\r\n\r\n```python\r\nfrom google.cloud.bigquery_storage_v1 import BigQueryWriteClient\r\nfrom google.cloud.bigquery_storage_v1.types import ProtoRows, ProtoSchema\r\nfrom google.cloud.bigquery_storage_v1.types.storage import AppendRowsRequest\r\nfrom google.cloud.bigquery_storage_v1.writer import AppendRowsStream\r\n\r\ns = AppendRowsStream(\r\n BigQueryWriteClient(),\r\n AppendRowsRequest(\r\n write_stream=\"STREAM NAME\",\r\n proto_rows=AppendRowsRequest.ProtoData(\r\n writer_schema=ProtoSchema(proto_descriptor=\"ADD PROTO DESCRIPTOR\"),\r\n ),\r\n ),\r\n)\r\n\r\ns.send(\r\n AppendRowsRequest(\r\n proto_rows=AppendRowsRequest.ProtoData(\r\n rows=ProtoRows(serialized_rows=[SERIALIZED ROWS TOTALLING ~9mb])\r\n )\r\n )\r\n)\r\n```\r\n\r\n#### Stack trace\r\n```\r\n2023-11-30 17:33:07,189 [DEBUG] Started helper thread Thread-ConsumeBidirectionalStream\r\n2023-11-30 17:33:14,180 [DEBUG] Empty queue and inactive call, exiting request generator.\r\n2023-11-30 17:33:14,266 [DEBUG] waiting for recv.\r\n2023-11-30 17:33:14,266 [DEBUG] recved response.\r\n2023-11-30 17:33:14,266 [DEBUG] waiting for recv.\r\n2023-11-30 17:33:14,268 [INFO] RPC termination has signaled streaming pull manager shutdown.\r\n2023-11-30 17:33:14,268 [ERROR] Thread-ConsumeBidirectionalStream caught unexpected exception and will exit.\r\nTraceback (most recent call last):\r\n File \".venv/lib/python3.9/site-packages/google/api_core/bidi.py\", line 662, in _thread_main\r\n response = self._bidi_rpc.recv()\r\n File \".venv/lib/python3.9/site-packages/google/api_core/bidi.py\", line 345, in recv\r\n return next(self.call)\r\n File \".venv/lib/python3.9/site-packages/google/api_core/grpc_helpers.py\", line 115, in __next__\r\n return next(self._wrapped)\r\n File \".venv/lib/python3.9/site-packages/grpc/_channel.py\", line 541, in __next__\r\n return self._next()\r\n File \".venv/lib/python3.9/site-packages/grpc/_channel.py\", line 965, in _next\r\n raise StopIteration()\r\nStopIteration\r\n2023-11-30 17:33:14,268 [DEBUG] Stopping consumer.\r\n2023-11-30 17:33:14,269 [INFO] Thread-ConsumeBidirectionalStream exiting\r\n```\r\n\r\n\r\n","author":{"url":"https://github.com/dhendry","@type":"Person","name":"dhendry"},"datePublished":"2023-11-30T18:16:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/560/python-api-core/issues/560"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:83df241f-7db7-6a7e-6de5-4354c37be8f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8DAC:1E086E:DD0197:14219D5:6A4E2C69 |
| html-safe-nonce | 932f68774c348a86931c7048ee2c6830b622965c527f8836ed17a5dda421fe86 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REFDOjFFMDg2RTpERDAxOTc6MTQyMTlENTo2QTRFMkM2OSIsInZpc2l0b3JfaWQiOiI2MDk4OTU3MjY0MDg4ODY5OTkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 655693a4835d475c7bc84191407e653263356477b925646d15915d5aeb60f05d |
| hovercard-subject-tag | issue:2019248844 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-api-core/560/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d5843f9e1096466ff0d273c09d02802091514d574afdb1bc34027d3896605bc1/googleapis/python-api-core/issues/560 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d5843f9e1096466ff0d273c09d02802091514d574afdb1bc34027d3896605bc1/googleapis/python-api-core/issues/560 |
| og:image:alt | tl;dr: Cause and fix I believe v2.13.0 introduced a regression here: v2.12.0...v2.13.0#diff-769a9f2c04700ff355d77a3292b7ff3cea5ff9bda91d0b31138eeb89fcd4d02dL95-L98 v2.12.0 code: def _is_active(self... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dhendry |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-api-core git https://github.com/googleapis/python-api-core.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992456 |
| octolytics-dimension-repository_nwo | googleapis/python-api-core |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992456 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-api-core |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d9dd20d38f8ae3c4cb6b597807431db300d0bd2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width