call-throttle
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.
Release files for call-throttle 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| call_throttle-1.0.1.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| call_throttle-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.8 kB
Release files / call_throttle-1.0.1.tar.gz
| Download URL | call_throttle-1.0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36b0d4b3a40db8db296bbe37ada4bac8a7cb20f7f8e74c9161ba00a1f9b0f8c2
|
|
BLAKE2b-256 checksum How to use checksums |
d9332c85abba5ba68c05b4d91e42b43690d3ca29333664b9460e61ac0f22605f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / call_throttle-1.0.1-py3-none-any.whl
| Download URL | call_throttle-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee9201c345a73627ba9e3e8a6c91a7c3d8f5c66d371dddf1f7f1cf99014b849f
|
|
BLAKE2b-256 checksum How to use checksums |
a3baf1e61ff3866382001047a637783754c3af4251a4ae89674b48b43a4f4d2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|