| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- Metadata-Version: 2.0
- Name: ratelim
- Version: 0.1.6
- Summary: Makes it easy to respect rate limits.
- Home-page: http://github.com/themiurgo/ratelim
- Author: Antonio Lima
- Author-email: anto87@gmail.com
- License: MIT
- Platform: UNKNOWN
- Requires-Dist: decorator
- Ratelim
- =======
- Ratelim is a simple Python library that limits the number of times a function can be called during a time interval. It is particularly useful when using online APIs, which commonly enforce rate limits.
- Features
- --------
- - Works in Py2 and Py3.
- - Greedy and patient rate limiting.
- - Preserves function signature.
- Installation
- ------------
- .. code-block:: bash
- $ pip install ratelim
- Usage
- -----
- Say you want to call a function at most for ``n_calls`` during a ``n_seconds`` time interval.
- .. code-block:: python
- # 10 times in 5 seconds
- @ratelim.greedy(10, 5)
- def hello():
- print("hello")
- The ``greedy`` rate limiter calls does not delay any function call until it's really necessary.
- In some scenarios, for example when crawling data from an API, you want to maximize the number
- of calls you make and you want to avoid sending them in short sequence. To this aim, we can
- use the ``patient`` rate limiter. It distributes calls evenly between each other.
- .. code-block:: python
- # 10 times in 5 seconds
- # Gets called at most every 0.5 seconds
- @ratelim.patient(10, 5)
- def hello():
- print("hello")
- LICENSE
- -------
- MIT.
|