Hacker News new | ask | show | jobs
by networked 693 days ago
Backoff doesn't look bad.

I have used two libraries for retrying in Python: retry (https://github.com/invl/retry) and 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) but more concise. Basic use requires as little code as retry and should be easy to remember.

1 comments

"stamina" is a wrapper for tenacity with nice defaults
I 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