throttle-controller
Motivation
This package provides a simple throttle controller for general use-cases. For example, you can use this package to throttle API requests to avoid rate-limiting.
Usage
from throttle_controller import SimpleThrottleController
throttle = SimpleThrottleController.create(default_cooldown_time=3.0)
throttle.wait_if_needed("http://example.com/path/to/api")
throttle.record_use_time_as_now("http://example.com/path/to/api")
... # requests
throttle.wait_if_needed("http://example.com/path/to/api") # wait 3.0 seconds
throttle.record_use_time_as_now("http://example.com/path/to/api")
with statement
from throttle_controller import SimpleThrottleController
throttle = SimpleThrottleController.create(default_cooldown_time=3.0)
for _ in range(10):
with throttle.use("http://example.com/path/to/api"):
# wait if cooldown needed
requests.get("http://example.com/path/to/api")
Caution
Currently this package supports only to use in single thread / single process use-cases.
LICENSE
The 3-Clause BSD License. See also LICENSE file.
Metadata
Release files for throttle-controller 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| throttle_controller-0.3.1.tar.gz | 32.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| throttle_controller-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.9 kB
Release files / throttle_controller-0.3.1.tar.gz
| Download URL | throttle_controller-0.3.1.tar.gz |
|---|---|
| Size | 32.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b0f19ea3d42d26af5518cd69d2d41d2ed82d1aed5ff80128d5e580d717bc1e2
|
|
BLAKE2b-256 checksum How to use checksums |
187d741afb3ed199e4e6230c4c5368b13a8143a06cedaa46df82beaf407531bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / throttle_controller-0.3.1-py3-none-any.whl
| Download URL | throttle_controller-0.3.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
621d32b3cceb6b839539dbd8a8e2f7dd9226f664c2754f8bdfb2030b9100f802
|
|
BLAKE2b-256 checksum How to use checksums |
8cb20a661ce3b4122a1ea0ceabcb6d866da4c88f471103159294d5061d1df311
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|