rate-limit-guard


Namerate-limit-guard JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/yourusername/rate-limiter
SummaryNone
upload_time2024-09-17 16:19:45
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.

## 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/yourusername/rate-limiter",
    "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/bc/af/fd72a1ddb612b0d97113831290ece5bb8762dfe2970cc703321de97dde8b/rate_limit_guard-0.1.2.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## 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```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": null,
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/yourusername/rate-limiter",
        "Repository": "https://github.com/yourusername/rate-limiter"
    },
    "split_keywords": [
        "rate limiter",
        " api",
        " decorator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2712b67a88d8899042a7ce2b5cbee32ac354d1dbb804f9cb92381b7f21577402",
                "md5": "43a2a656c99da32ea6abae460396ba39",
                "sha256": "7b334e745831a5483b1db6998bf1ced6ded4d18057fac5eb3ba2ef0535079879"
            },
            "downloads": -1,
            "filename": "rate_limit_guard-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "43a2a656c99da32ea6abae460396ba39",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 3470,
            "upload_time": "2024-09-17T16:19:44",
            "upload_time_iso_8601": "2024-09-17T16:19:44.730556Z",
            "url": "https://files.pythonhosted.org/packages/27/12/b67a88d8899042a7ce2b5cbee32ac354d1dbb804f9cb92381b7f21577402/rate_limit_guard-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bcaffd72a1ddb612b0d97113831290ece5bb8762dfe2970cc703321de97dde8b",
                "md5": "ab95ea480a44adbfdf7781734aa6e4d2",
                "sha256": "c3a481955369104f3e6685c90ceaed74b32701a8354c5b45846e1749387b7174"
            },
            "downloads": -1,
            "filename": "rate_limit_guard-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ab95ea480a44adbfdf7781734aa6e4d2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 2657,
            "upload_time": "2024-09-17T16:19:45",
            "upload_time_iso_8601": "2024-09-17T16:19:45.957279Z",
            "url": "https://files.pythonhosted.org/packages/bc/af/fd72a1ddb612b0d97113831290ece5bb8762dfe2970cc703321de97dde8b/rate_limit_guard-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-17 16:19:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "rate-limiter",
    "github_not_found": true,
    "lcname": "rate-limit-guard"
}
        
Elapsed time: 4.93620s