ratelimit_requests_cache
Ratelimit requests in Python, but only if they're not served from the cache
This package combines the best bits of the ratelimit module and the requests_cache module.
It will rate limit outgoing requests, but not count invocations if a request can be served from the cache.
Usage
import requests
import requests_cache
from ratelimit import sleep_and_retry
from ratelimit_requests_cache import limits_if_not_cached
@sleep_and_retry
@limits_if_not_cached(calls=1, period=1)
def get_from_httpbin(i):
return requests.get(f'https://httpbin.org/anything?i={i}')
# Enable requests caching
requests_cache.install_cache()
# Notice that only the first ten requests will be ratelimited to 1 request / second
# After that, it's a lot quicker since requests can be served from the cache
# and the ratelimiter does not engage
for i in range(100):
get_from_httpbin(i % 10)
print(i)
Installation
python3 -m pip install ratelimit_requests_cache
Metadata
Release files for ratelimit_requests_cache 2023.10.30
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 |
|---|---|---|---|---|
| ratelimit_requests_cache-2023.10.30.tar.gz | 2.6 kB | Without provenance | Details for ratelimit_requests_cache-2023.10.30.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ratelimit_requests_cache-2023.10.30-py3-none-any.whl | Python 3 | none | any | Details for ratelimit_requests_cache-2023.10.30-py3-none-any.whl |
Total release size: 6.2 kB
Release files / ratelimit_requests_cache-2023.10.30.tar.gz
| Download URL | ratelimit_requests_cache-2023.10.30.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5a182db7768d902a05a39c38d71e592296b90164d3ca4a544995e988d832cd0
|
|
BLAKE2b-256 checksum How to use checksums |
b31984e9ade47eef5630043ee7452544096d2dc5d84d04282358f27462be90b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.8.0 CPython/3.11.6
|
Release files / ratelimit_requests_cache-2023.10.30-py3-none-any.whl
| Download URL | ratelimit_requests_cache-2023.10.30-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba1e54454f4e34b1bd5923f7c9f000ef7c3c6e2c53f6e11e10d1ccd2640ecdd0
|
|
BLAKE2b-256 checksum How to use checksums |
5a627b2e22758595a7a4ec341a8b49b8d2316319d2d7060af5b71ca8a1ec8b6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.8.0 CPython/3.11.6
|
Security for ratelimit_requests_cache 2023.10.30
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.