rate-limit-guard


Namerate-limit-guard JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/izofat/rate-limit-guard
SummaryNone
upload_time2024-10-28 21:12:08
maintainerNone
docs_urlNone
authorGorkem Kacar
requires_python<4.0,>=3.11
licenseMIT
keywords rate limiter api decorator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Rate Limiting Decorator

This Python module provides a `rate_limit_decorator` that allows you to limit the rate at which a function can be called. It supports both synchronous and asynchronous functions, making it versatile for various applications.

## Installation

Install the rate-limit-guard package via pip:

```bash
pip install rate-limit-guard
```

Once installed, import rate_limit_decorator into your project and apply it to your functions to enable rate limiting.

## Features

- **Rate Limiting**: Control the maximum number of function calls within a given time interval.
- **Support for Asynchronous and Synchronous Functions**: The decorator works seamlessly with both types of functions.
- **Easy Integration**: Simply apply the decorator to your function, and it will handle rate limiting for you.

## Usage

Here’s a basic example of how to use the `rate_limit_decorator`:

### Synchronous

```python
from rate_limit_guard import rate_limit_decorator

@rate_limit_decorator(interval=1, max_calls=5)
def my_function():
    print("Function is called")

def main():
    try:
        for _ in range(10):
            my_function()
    except RuntimeError:
        # this will be raised after the rate limit is reached
        pass
```

### Asynchronous

```python
from rate_limit_guard import rate_limit_decorator
import asyncio

@rate_limit_decorator(interval=1, max_calls=5)
async def my_async_function():
    print("Async function is called")
    await asyncio.sleep(0.5)

async def main():
    try:
        for _ in range(10):
            await my_async_function()
    except RuntimeError:
        # this will be raised after the rate limit is reached
        pass
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/izofat/rate-limit-guard",
    "name": "rate-limit-guard",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "rate limiter, API, decorator",
    "author": "Gorkem Kacar",
    "author_email": "g.kacar@digitastic.app",
    "download_url": "https://files.pythonhosted.org/packages/82/2b/5eeccaddc789ff1657bfc7bf35957d3e504fdfb1095991484534c1b95852/rate_limit_guard-0.1.3.tar.gz",
    "platform": null,
    "description": "# Rate Limiting Decorator\n\nThis Python module provides a `rate_limit_decorator` that allows you to limit the rate at which a function can be called. It supports both synchronous and asynchronous functions, making it versatile for various applications.\n\n## Installation\n\nInstall the rate-limit-guard package via pip:\n\n```bash\npip install rate-limit-guard\n```\n\nOnce installed, import rate_limit_decorator into your project and apply it to your functions to enable rate limiting.\n\n## Features\n\n- **Rate Limiting**: Control the maximum number of function calls within a given time interval.\n- **Support for Asynchronous and Synchronous Functions**: The decorator works seamlessly with both types of functions.\n- **Easy Integration**: Simply apply the decorator to your function, and it will handle rate limiting for you.\n\n## Usage\n\nHere\u2019s a basic example of how to use the `rate_limit_decorator`:\n\n### Synchronous\n\n```python\nfrom rate_limit_guard import rate_limit_decorator\n\n@rate_limit_decorator(interval=1, max_calls=5)\ndef my_function():\n    print(\"Function is called\")\n\ndef main():\n    try:\n        for _ in range(10):\n            my_function()\n    except RuntimeError:\n        # this will be raised after the rate limit is reached\n        pass\n```\n\n### Asynchronous\n\n```python\nfrom rate_limit_guard import rate_limit_decorator\nimport asyncio\n\n@rate_limit_decorator(interval=1, max_calls=5)\nasync def my_async_function():\n    print(\"Async function is called\")\n    await asyncio.sleep(0.5)\n\nasync def main():\n    try:\n        for _ in range(10):\n            await my_async_function()\n    except RuntimeError:\n        # this will be raised after the rate limit is reached\n        pass\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": null,
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/izofat/rate-limit-guard",
        "Repository": "https://github.com/izofat/rate-limit-guard"
    },
    "split_keywords": [
        "rate limiter",
        " api",
        " decorator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f90fc960b5b33d20ea7bb0eea26a3cb0dc5877e246e9e6e9fe71ba4373fc9c0c",
                "md5": "a9770a490b1d71bdae3a08007e6e09d7",
                "sha256": "956365ea14b3307e2ae98c2510242f6df5de61a5eb3a1db4a5b0648d87eb438b"
            },
            "downloads": -1,
            "filename": "rate_limit_guard-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a9770a490b1d71bdae3a08007e6e09d7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 3542,
            "upload_time": "2024-10-28T21:12:06",
            "upload_time_iso_8601": "2024-10-28T21:12:06.971854Z",
            "url": "https://files.pythonhosted.org/packages/f9/0f/c960b5b33d20ea7bb0eea26a3cb0dc5877e246e9e6e9fe71ba4373fc9c0c/rate_limit_guard-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "822b5eeccaddc789ff1657bfc7bf35957d3e504fdfb1095991484534c1b95852",
                "md5": "035428dcdf917a6f1cd9731d4eb4e0f0",
                "sha256": "b6484d9391a8481ae0b98395380273ff207f4722f4401dc5428ae47647c45155"
            },
            "downloads": -1,
            "filename": "rate_limit_guard-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "035428dcdf917a6f1cd9731d4eb4e0f0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 2751,
            "upload_time": "2024-10-28T21:12:08",
            "upload_time_iso_8601": "2024-10-28T21:12:08.603319Z",
            "url": "https://files.pythonhosted.org/packages/82/2b/5eeccaddc789ff1657bfc7bf35957d3e504fdfb1095991484534c1b95852/rate_limit_guard-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-28 21:12:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "izofat",
    "github_project": "rate-limit-guard",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "rate-limit-guard"
}
        
Elapsed time: 1.53469s