Skip to main content

Installing

pip3 install throttle

Simple Usage

import time
import throttle

# limit to 3 calls
# allow more every 1 second
@throttle.wrap(1, 3)
def aesthetic(*values):

  return ' '.join(values).upper()

for index in range(10):

  result = aesthetic('beautiful')

  success = not result is throttle.fail

  print(index, success)

  time.sleep(0.23)

Complex Usage

import time
import random
import throttle

# allow more every 1 second
delay = 1

# limit to 3 calls
limit = 3

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

# or Static()
valve = throttle.Valve()

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

  item = random.randrange(0, 8)

  allow = valve.check(delay, limit, item, key = key)

  print(item, allow)

  time.sleep(0.23)

Metadata

Release files for throttle 0.2.2

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 0.2.2
File Size Uploaded
throttle-0.2.2.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for throttle 0.2.2
File Interpreter ABI Platform
throttle-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / throttle-0.2.2.tar.gz

Download URL throttle-0.2.2.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5c949b0ae118c63e9e1be3e927d7ecdc9c46231248374d4d1cab95123e380e0c
BLAKE2b-256 checksum
How to use checksums
935db2ccc39e665ee189eb465c1e637337150e72a65a160dbfcefd0b7b124e94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.1

Release files / throttle-0.2.2-py3-none-any.whl

Download URL throttle-0.2.2-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8bd279e062190708fc1df2bbf0aea5f8460bf7893114ebdb2789ce7a286e9fe
BLAKE2b-256 checksum
How to use checksums
66b752f82631b668ec9f0fe28322758d78e75334added5b012362393e5cb7849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.0.0

2 release files

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