Skip to main content

A decorator used to throttle calls of regular functions and asyncio coroutines.

Project description

call-throttle

python version downloads format

This package provides decorators which can be used to throttle calls of regular Python functions and asyncio coroutines.

Install

Use pip package installer for Python:

python -m pip install --upgrade call-throttle

Make sure you have Python 3.9 or later installed.

Usage

Here is a basic example for how to use the throttle decorator with functions and coroutines:

import time
import asyncio
from datetime import timedelta

from call_throttle import throttle


@throttle(calls=1, period=timedelta(seconds=2))
def func():
    time.sleep(1)


@throttle(calls=2, period=0.2)
async def coro():
    await asyncio.sleep(0.05)

If passing raise_on_throttle=True to @throttle(...), then a call_throttle.ThrottleException is raised when a decorated function or coroutine is called more times than the defined calls limit within the specified time period.

License

This is a free software licensed under the terms of the MIT License.

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

call_throttle-1.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

call_throttle-1.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file call_throttle-1.0.1.tar.gz.

File metadata

  • Download URL: call_throttle-1.0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for call_throttle-1.0.1.tar.gz
Algorithm Hash digest
SHA256 36b0d4b3a40db8db296bbe37ada4bac8a7cb20f7f8e74c9161ba00a1f9b0f8c2
MD5 5df142fb0b4122b14d01940b477708ab
BLAKE2b-256 d9332c85abba5ba68c05b4d91e42b43690d3ca29333664b9460e61ac0f22605f

See more details on using hashes here.

File details

Details for the file call_throttle-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: call_throttle-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for call_throttle-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee9201c345a73627ba9e3e8a6c91a7c3d8f5c66d371dddf1f7f1cf99014b849f
MD5 b1c5d1c0a5f8e4c1ffb76671d7bb6b54
BLAKE2b-256 a3baf1e61ff3866382001047a637783754c3af4251a4ae89674b48b43a4f4d2a

See more details on using hashes here.

Supported by

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