Show HN: New BucketRateLimiter Python package to rate limit requests to APIs
pypi.org
pypi.org
Something that seems missing is a pluggable backend for when you need to coordinate rate-limiting across machines. This library allows for a variety of backends:
In a practical sense, a 429 is just a 503. Back off and try again if you have time, otherwise fail. It's the passive-aggressive "I'm not providing service to your well-formed request, but it's you and not me" response code.
This kind of code is useful anywhere you have message buses with finite resources, which is a lot broader than just HTTP. It lets you separate the how of data processing and transformation from the when. I keep a token bucket header in my personal toolbox for embedded work because it's just such a common and simple building block.