hallazzang / asyncio-throttle Goto Github PK
View Code? Open in Web Editor NEWSimple, easy-to-use throttler for asyncio.
License: MIT License
Simple, easy-to-use throttler for asyncio.
License: MIT License
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!
Is this throttler composable/chainable? Can I wrap one in another?
In other words: Can I use this in some layered fashion that implements both a N per second throttle but also a M per minute throttle?
For example: No more than 3 concurrent requests per second and no more than 100 requests per minute.
I think the answer is "no" but maybe there's a clean way of combining/layering/composing this that could yield such functionality?
I love how simple this implementation is and I don't want to complicate it with such features, but if a chain of these can be used to implement such functionality, that would be awesome. I'm just not experienced enough at Python to see how to.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.