A simple throttling controller
Project description
throttle-controller
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file throttle_controller-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: throttle_controller-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6bdb2c04309840333d537315a7e2e96fdf225e00f1847f791367e50bf6dcdaf |
|
MD5 | c6edb175aee0d55e33616cce371bf4c4 |
|
BLAKE2b-256 | abc6c7edf36cee2b00c42e05d10ae031f130e78167ecc27a48929ab966b10873 |