Retries

A retry automatically reruns an operation that failed because of a temporary error (network, unavailability). The number of attempts is limited and the tries are spaced out with an increasing delay (exponential backoff). It is only safe if the operation is idempotent; a logic error is not fixed by retrying.

Example

for tentative in range(3):
    try:
        return appeler_api()
    except TimeoutError:
        time.sleep(2 ** tentative)

Related concepts

The whole glossary