Search⌘ K
AI Features

Naive Retrying

Explore naive retrying methods in Python including basic retries, retry and sleep patterns, and exponential backoff strategies. Understand how these approaches affect system congestion and stability when handling failures in distributed applications.

There’s a common pattern that can be seen across all sorts of programs that can be summarized with the word “retrying”. It is directly tied to the idea of trying something again that returned an error or raised an exception when it was not expected.

Basic retrying pattern

The basic pattern that most developers implement looks like what is shown in the following example.

Python 3.8
while True:
try:
do_something()
except:
pass
else:
break

The above example does not provide any down time for the called function. Usually, smarter strategies are implemented. ...