Closed
Description
Currently our retry logic pulls the next sleep time from the generator before starting an rpc. This allows us to immediately fail with a ValueError if the generator stops providing backoff values
The downside of this approach is that the backoff is locked in before the rpc is attempted.
Bigtable has a feature where the server can provide a backoff value to the client for the next attempt. The design of Python's retry classes is flexible enough to allow this, except for the fact that the next backoff value is locked in early.
To support this feature, I suggest that we only call the backoff generator when we are ready for the next sleep.