httpx-ratelimit
Simple wrapper around PyrateLimiter that adds integration with httpx library
Usage
Using per_* kwargs:
from time import time
from httpx import Client
from httpx_ratelimiter import LimiterTransport
# Apply a rate limit of 5 requests per second to all requests
# if wait time between request will be more than 600ms, raise an BucketFullException
with Client(transport=LimiterTransport(per_second=5, max_delay=600)) as c:
start = time()
for _i in range(100):
print(
f'[t + {time() - start: .2f}] got response: {c.get("https://httpbin.org/status/200,429")}'
)
Using custom list of rates
from time import time
from httpx import Client
from httpx_ratelimiter import LimiterTransport
from pyrate_limiter import Limiter, Rate, Duration
# limit 5 requests over 2 seconds and 10 requests over 1 minute
rates = [Rate(5, Duration.SECOND * 2), Rate(10, Duration.MINUTE)]
# if wait time between request will be more than 600ms, silently fail
with Client(transport=LimiterTransport(rates=rates, max_delay=600, raise_when_fail=False)) as c:
start = time()
for _i in range(100):
print(
f'[t + {time() - start: .2f}] got response: {c.get("https://httpbin.org/status/200,429")}'
)
Thanks
Thank to original Requests-ratelimiter author for idea and backbone of a project.
Metadata
Release files for httpx_ratelimiter 0.0.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 |
|---|---|---|---|---|
| httpx_ratelimiter-0.0.6.tar.gz | 7.4 kB | Without provenance | Details for httpx_ratelimiter-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| httpx_ratelimiter-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for httpx_ratelimiter-0.0.6-py3-none-any.whl |
Total release size: 13.3 kB
Release files / httpx_ratelimiter-0.0.6.tar.gz
| Download URL | httpx_ratelimiter-0.0.6.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
30b23e749c3c639e9d4fc3ff35ff883a05c563469b0a2c79b60a13e9c7826931
|
|
BLAKE2b-256 checksum How to use checksums |
38358912e02d6e09f58bc024657592799abffc69b01c65fcc1fcd1af657f1f7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / httpx_ratelimiter-0.0.6-py3-none-any.whl
| Download URL | httpx_ratelimiter-0.0.6-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b81bb25d4cf5cf9b7a817f93d4df2ed3bd2571f74bfc0701450440285c131ec
|
|
BLAKE2b-256 checksum How to use checksums |
ea9affb494b35cd8e52ec7462afd5f7564afc4b7b769bd4a5c19c5e3d8d9d604
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for httpx_ratelimiter 0.0.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.