nemoguardrails.library.clavata.utils
Module Contents
Classes
Functions
Data
API
Exception
Bases: Exception
Exception raised when the maximum number of retries is exceeded.
Handles calculation of the delay for a specific attempt. Note that we specifically ask for the number of retries, not the number of attempts, because the first attempt is the initial call and we want the first delay to be raised to the power of 0.
Using “retries” instead of “attempts” makes it clearer what the input is, even though a value called “attempts” is being passed in below.
Because this is an exponential backoff, the factor of increase is always 2.
Parameters:
retries
The number of retries made so far.
initial_delay
The initial delay.
max_delay
The maximum delay.
jitter
Whether to apply jitter to the delay. We use a full-jitter approach.
Exponential backoff retry mechanism.