GithubHelp home page GithubHelp logo

hallazzang / asyncio-throttle Goto Github PK

View Code? Open in Web Editor NEW
118.0 5.0 12.0 22 KB

Simple, easy-to-use throttler for asyncio.

License: MIT License

Python 100.00%
python asyncio throttle throttler throttling

asyncio-throttle's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

asyncio-throttle's Issues

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!

Question: Is this throttler composable/chainable?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.