4 ms·
Backoff doesn't look bad. I have used two libraries for retrying in Python: retry (https://github.com/invl/retry https://github.com/invl/retry) and Tenacity (h
by networked 2y ago
Backoff doesn't look bad.
I have used two libraries for retrying in Python: retry (https://github.com/invl/retry https://github.com/invl/retry) and Tenacity (https://github.com/jd/tenacity https://github.com/jd/tenacity).
Tenacity actually helped me with a recent GPT-4o mini experiment,
when OpenRouter gave me an error after a couple hundred requests.
I can recommend Tenacity.
A downside is that the API is fairly complex and verbose.
You will probably look it up each time if you don't use it often (or rely on an IDE or LLM).
Backoff seems somewhat less flexible than Tenacity (https://github.com/litl/backoff/issues/125 https://github.com/litl/backoff/issues/125) but more concise.
Basic use requires as little code as retry and should be easy to remember.
- ddorian43 2y ago"stamina" is a wrapper for tenacity with nice defaults
- networked 2y agoI didn't know about stamina. I like it a lot at first glance. Thanks for telling me. Compared to Backoff, it has docs, and you don't need to tell it each time you want exponential backoff. (Exponential backoff is what you usually want when you don't want a fixed delay.) You can use Tenacity directly when you need something more complex. https://github.com/hynek/stamina https://github.com/hynek/stamina