Skip to content

Commit 17ff5f1

Browse files
daniel-sanchegcf-owl-bot[bot]partheavchudnov-g
authored
feat: retry and retry_async support streaming rpcs (#495)
From #485: > Server streaming libraries return an iterable that can asynchronously yield data from the backend over time. Some of our libraries need to provide a wrapper around the raw stream to do some local processing, before passing the data to the user. > > It would be useful to wrap this whole pipeline in a retry decorator, so that if the stream breaks mid-way through, we can recover and continue yielding data through our generator as if nothing happened. > > Unfortunately, the current implementation returns the result of the target function directly, so generators will not yield values and exceptions through the retry block This PR addresses the issue by adding retry_target_generator functions to both the async and sync retry modules, which yield through the target rather than call it directly. Generator mode can be enabled using the is_generator argument on the decorator. Fixes #485 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]> Co-authored-by: Victor Chudnovsky <[email protected]>
1 parent 4d7d2ed commit 17ff5f1

16 files changed

+2891
-1106
lines changed

google/api_core/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020
from google.api_core import version as api_core_version
2121

2222
__version__ = api_core_version.__version__
23+
24+
# for backwards compatibility, expose async unary retries as google.api_core.retry_async
25+
from .retry import retry_unary_async as retry_async # noqa: F401

0 commit comments

Comments
 (0)