asyncio-throttle
asyncio-throttle copied to clipboard
Suggestion: add an example for REST polling use case
It may be helpful to add an example of using this package for REST polling (e.g., continuously fetching data from a REST API), because specifying a relatively long period
(e.g., 60 seconds) can cause an unnecessary spike in the number of requests at the beginning of every period
. Additionally, users of this package may likely be interested in this specific use case.
For instance, if I set throttler = Throttler(rate_limit=500, period=60)
, 500 requests would be made at the very beginning of the 60 seconds period, and then nothing would happen until the next 60 seconds mark. This resulted in a lot of 429 (too many requests) response codes. To get around this, I had to specify rate_limit
as 1
and period
as 60/500
. Of course, the possibility of getting 429 responses also depend on the tolerance of the API server in question.
That said, I believe the above issue is worth considering, unless I am doing something wrong or do not know what I was doing. Anyways, thanks for maintaining this package!