Skip to main content

A simple throttling controller

Project description

throttle-controller

Python PyPI version shields.io License codecov

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 Distribution

throttle-controller-0.0.6.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

throttle_controller-0.0.6-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file throttle-controller-0.0.6.tar.gz.

File metadata

  • Download URL: throttle-controller-0.0.6.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for throttle-controller-0.0.6.tar.gz
Algorithm Hash digest
SHA256 7d41562e16706c5b530a1b43ca45a56cc19fd459d260ed49682957ce905fb9db
MD5 636b7bcd6befb8bb389adb82c4ba6304
BLAKE2b-256 81fd1c8026762c026fd4560fab8dd932a5ee0d4c82bb5f0bd5896ed7a08a4c64

See more details on using hashes here.

File details

Details for the file throttle_controller-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for throttle_controller-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ada010f4072ffdda0cce54ac3057142e660d62335d2488a41ac3f6256798414f
MD5 f56ea9b1f8dee66a8841c77a270fc349
BLAKE2b-256 6ea7ea1a2dafa5ec35c563a52a9621c7d2da2ad084ef6ea7f13a8e290aa223c2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page