Subclassing requests.exceptions.Timeout keeps the old handlers working, and that includes retry wrappers. A tenacity or backoff decorator set to retry on Timeout will now retry a DeadlineExceeded as well, so get_json with deadline_s=4 and three attempts can hold the caller for 12 seconds plus backoff, past the 10 second endpoint budget in your example.
I'd compute the deadline once, before the retry loop, and give each attempt only the time left. The attempts then share one budget instead of each getting a fresh four seconds.
Mike Dabydeen
VP Engineering @ UREEQA
Subclassing requests.exceptions.Timeout keeps the old handlers working, and that includes retry wrappers. A tenacity or backoff decorator set to retry on Timeout will now retry a DeadlineExceeded as well, so get_json with deadline_s=4 and three attempts can hold the caller for 12 seconds plus backoff, past the 10 second endpoint budget in your example.
I'd compute the deadline once, before the retry loop, and give each attempt only the time left. The attempts then share one budget instead of each getting a fresh four seconds.