Commit 17ff5f1
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 <partheniou@google.com>
Co-authored-by: Victor Chudnovsky <vchudnov@google.com>1 parent 4d7d2ed commit 17ff5f1
File tree
16 files changed
+2891
-1106
lines changed- google/api_core
- retry
- tests
- asyncio/retry
- unit/retry
16 files changed
+2891
-1106
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments