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
$ pip install ratelim
Usage
Say you want to call a function at most for n_calls during a n_seconds time interval.
# 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.
# 10 times in 5 seconds
# Gets called at most every 0.5 seconds
@ratelim.patient(10, 5)
def hello():
print("hello")
LICENSE
MIT.
Metadata
Release files for ratelim 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ratelim-0.1.6.tar.gz | 2.8 kB | Without provenance | Details for ratelim-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ratelim-0.1.6-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for ratelim-0.1.6-py2.py3-none-any.whl |
Total release size: 6.8 kB
Release files / ratelim-0.1.6.tar.gz
| Download URL | ratelim-0.1.6.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
826d32177e11f9a12831901c9fda6679fd5bbea3605910820167088f5acbb11d
|
|
BLAKE2b-256 checksum How to use checksums |
c55ae1440017bccb14523bb76356e6f3a5468386b8a9192bd901e98babd1a1ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / ratelim-0.1.6-py2.py3-none-any.whl
| Download URL | ratelim-0.1.6-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e1a7dd39e6b552b7cc7f52169cd66cdb826a1a30198e355d7016012987c9ad08
|
|
BLAKE2b-256 checksum How to use checksums |
f2987e6d147fd16a10a5f821db6e25f192265d6ecca3d82957a4fdd592cad49c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ratelim 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.