Skip to main content

Throttling utilities.

Project description

Installing

pip3 install throttle

Usage

import time
import random
import throttle

delay = 1
# remove values every 1 second

limit = 3
# hold up to 3 values

key = lambda value: value < 5
# only check values less than 5 against the limit

valve = throttle.create(delay, limit, key = key)

# make some quick calls
for index in range(10):

  item = random.randrange(0, 8)

  allow = valve(item)

  print(item, allow)

  time.sleep(0.25)

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-0.0.0.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

throttle-0.0.0-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

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