Title: feat: allow disabling response stream pre-fetch by plamut · Pull Request #30 · googleapis/python-api-core · GitHub
Open Graph Title: feat: allow disabling response stream pre-fetch by plamut · Pull Request #30 · googleapis/python-api-core
X Title: feat: allow disabling response stream pre-fetch by plamut · Pull Request #30 · googleapis/python-api-core
Description: Closes #25. This PR adds the ability to disable automatically pre-fetching the first item of a stream returned by *-Stream gRPC callables. This hook will be used in PubSub to fix the stalled stream issue, while also not affecting Firestore, since the default behavior is preserved. I realize the fix is far from ideal, but it's the least ugly among the approaches I tried, e.g. somehow passing the flag through ResumableBidiRpc (it's a messy rabbit hole). On the PubSub side monkeypatching the generated SubscriberClient will be needed, but it's a (relatively) clean one-liner: diff --git google/cloud/pubsub_v1/gapic/subscriber_client.py google/cloud/pubsub_v1/gapic/subscriber_client.py index e98a686..1d6c058 100644 --- google/cloud/pubsub_v1/gapic/subscriber_client.py +++ google/cloud/pubsub_v1/gapic/subscriber_client.py @@ -1169,6 +1169,8 @@ class SubscriberClient(object): default_timeout=self._method_configs["StreamingPull"].timeout, client_info=self._client_info, ) + # TODO: explain this monkeypatch! + self.transport.streaming_pull._prefetch_first_result_ = False return self._inner_api_calls["streaming_pull"]( requests, retry=retry, timeout=timeout, metadata=metadata If/when we merge this, we should also release it, and then we can add != 1.17.0 to the google-api-core version pin in PubSub. PR checklist Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea Ensure the tests and linter pass Code coverage does not decrease (if any source code was changed) Appropriate docs were updated (if necessary)
Open Graph Description: Closes #25. This PR adds the ability to disable automatically pre-fetching the first item of a stream returned by *-Stream gRPC callables. This hook will be used in PubSub to fix the stalled stream...
X Description: Closes #25. This PR adds the ability to disable automatically pre-fetching the first item of a stream returned by *-Stream gRPC callables. This hook will be used in PubSub to fix the stalled stream...
Opengraph URL: https://github.com/googleapis/python-api-core/pull/30
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:61427f3d-ff4d-390a-5a96-9e7f59366211 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CF8C:286F17:3A0384:4E019A:6A4D9FA3 |
| html-safe-nonce | f7392f6ab9f3d802d2b83c6d77fd0c322127136e2ff43c440ee09658e7fb985c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjhDOjI4NkYxNzozQTAzODQ6NEUwMTlBOjZBNEQ5RkEzIiwidmlzaXRvcl9pZCI6IjI4MzYxNTk2NzQwNTQ0NTExMDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4ff7d7f09235998c4ede503bec09c211c17facfc345fde92e86ae2e87cd7dea0 |
| hovercard-subject-tag | pull_request:421371060 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/googleapis/python-api-core/pull/30/files |
| twitter:image | https://avatars.githubusercontent.com/u/1235663?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1235663?s=400&v=4 |
| og:image:alt | Closes #25. This PR adds the ability to disable automatically pre-fetching the first item of a stream returned by *-Stream gRPC callables. This hook will be used in PubSub to fix the stalled stream... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7f13faa65cccc9b729d674da83335d5dcfdfd193 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width