# call-throttle
![python](https://img.shields.io/pypi/pyversions/call-throttle.svg)
![version](https://img.shields.io/pypi/v/call-throttle.svg)
![downloads](https://img.shields.io/pypi/dm/call-throttle.svg)
![format](https://img.shields.io/pypi/format/call-throttle.svg)
This package provides decorators which can be used to throttle calls of regular Python functions and asyncio coroutines.
## Install
Use [pip](https://pip.pypa.io/en/stable/) package installer for Python:
```bash
python -m pip install --upgrade call-throttle
```
Make sure you have Python 3.7 or later installed.
## Usage
Here is a basic example for how to use the `throttle` decorator with functions and coroutines:
```python
import time
import asyncio
from datetime import timedelta
from call_throttle import throttle
@throttle(calls=1, period=timedelta(seconds=1))
def func():
time.sleep(1)
@throttle(calls=1, period=timedelta(seconds=2))
async def coro():
await asyncio.sleep(1)
```
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/ktolstikhin/call-throttle.git",
"name": "call-throttle",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "decorator,throttle,ratelimit",
"author": "Konstantin Tolstikhin",
"author_email": "k.tolstikhin@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/bd/d3/a5e8f908aa79c15f4194d0539a3eac500ee2a78d2a211dbd788590892f2a/call-throttle-0.4.0.tar.gz",
"platform": null,
"description": "# call-throttle\n\n![python](https://img.shields.io/pypi/pyversions/call-throttle.svg)\n![version](https://img.shields.io/pypi/v/call-throttle.svg)\n![downloads](https://img.shields.io/pypi/dm/call-throttle.svg)\n![format](https://img.shields.io/pypi/format/call-throttle.svg)\n\nThis package provides decorators which can be used to throttle calls of regular Python functions and asyncio coroutines.\n\n## Install\n\nUse [pip](https://pip.pypa.io/en/stable/) package installer for Python:\n```bash\npython -m pip install --upgrade call-throttle\n```\nMake sure you have Python 3.7 or later installed.\n\n## Usage\n\nHere is a basic example for how to use the `throttle` decorator with functions and coroutines:\n```python\nimport time\nimport asyncio\nfrom datetime import timedelta\n\nfrom call_throttle import throttle\n\n\n@throttle(calls=1, period=timedelta(seconds=1))\ndef func():\n time.sleep(1)\n\n\n@throttle(calls=1, period=timedelta(seconds=2))\nasync def coro():\n await asyncio.sleep(1)\n```\nIf 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`.\n\n## License\n\nThis is a free software licensed under the terms of the MIT License.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A decorator used to throttle calls of regular functions and asyncio coroutines.",
"version": "0.4.0",
"project_urls": {
"Homepage": "https://github.com/ktolstikhin/call-throttle.git"
},
"split_keywords": [
"decorator",
"throttle",
"ratelimit"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "56491eae9f207f2e8f4bd35b1543708d277eacae2235ca7c09ab1570ec3ee5ca",
"md5": "4312ceaa4754f3c73965339d1add6bd2",
"sha256": "78492d7c08340c5c5f39a6bd51b8f324928eda5927956a2796ce1b98bfeccf5a"
},
"downloads": -1,
"filename": "call_throttle-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4312ceaa4754f3c73965339d1add6bd2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4572,
"upload_time": "2023-11-13T07:07:44",
"upload_time_iso_8601": "2023-11-13T07:07:44.337884Z",
"url": "https://files.pythonhosted.org/packages/56/49/1eae9f207f2e8f4bd35b1543708d277eacae2235ca7c09ab1570ec3ee5ca/call_throttle-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bdd3a5e8f908aa79c15f4194d0539a3eac500ee2a78d2a211dbd788590892f2a",
"md5": "be8041c0de043faacb0c981f752f1887",
"sha256": "c9e216f9832340e7a7b7efd75bb30135fa17ea743763884462eda53b09c189db"
},
"downloads": -1,
"filename": "call-throttle-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "be8041c0de043faacb0c981f752f1887",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 3768,
"upload_time": "2023-11-13T07:07:46",
"upload_time_iso_8601": "2023-11-13T07:07:46.822057Z",
"url": "https://files.pythonhosted.org/packages/bd/d3/a5e8f908aa79c15f4194d0539a3eac500ee2a78d2a211dbd788590892f2a/call-throttle-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-13 07:07:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ktolstikhin",
"github_project": "call-throttle",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "build",
"specs": [
[
"==",
"1.0.3"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"68.2.2"
]
]
},
{
"name": "twine",
"specs": [
[
"==",
"4.0.2"
]
]
}
],
"lcname": "call-throttle"
}