Skip to main content

throttle-controller

Python PyPI version shields.io License codecov

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)

Source distribution for throttle-controller 0.3.1
File Size Uploaded
throttle_controller-0.3.1.tar.gz 32.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for throttle-controller 0.3.1
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.8

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page