ratelim


Nameratelim JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttp://github.com/themiurgo/ratelim
SummaryMakes it easy to respect rate limits.
upload_time2015-02-27 18:06:08
maintainerNone
docs_urlNone
authorAntonio Lima
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements decorator
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Ratelim
=======

Ratelim is a simple Python library that limits the number of times a function can be called during a time interval. It is particularly useful when using online APIs, which commonly enforce rate limits.

Features
--------

- Works in Py2 and Py3.
- Greedy and patient rate limiting.
- Preserves function signature.

Installation
------------

.. code-block:: bash

    $ pip install ratelim

Usage
-----

Say you want to call a function at most for ``n_calls`` during a ``n_seconds`` time interval.

.. code-block:: python

    # 10 times in 5 seconds
    @ratelim.greedy(10, 5)
    def hello():
        print("hello")


The ``greedy`` rate limiter calls does not delay any function call until it's really necessary.

In some scenarios, for example when crawling data from an API, you want to maximize the number
of calls you make and you want to avoid sending them in short sequence. To this aim, we can
use the ``patient`` rate limiter. It distributes calls evenly between each other.

.. code-block:: python

    # 10 times in 5 seconds
    # Gets called at most every 0.5 seconds
    @ratelim.patient(10, 5)
    def hello():
        print("hello")

LICENSE
-------

MIT.
            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/themiurgo/ratelim",
    "name": "ratelim",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Antonio Lima",
    "author_email": "anto87@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c5/5a/e1440017bccb14523bb76356e6f3a5468386b8a9192bd901e98babd1a1ea/ratelim-0.1.6.tar.gz",
    "platform": "UNKNOWN",
    "description": "Ratelim\n=======\n\nRatelim is a simple Python library that limits the number of times a function can be called during a time interval. It is particularly useful when using online APIs, which commonly enforce rate limits.\n\nFeatures\n--------\n\n- Works in Py2 and Py3.\n- Greedy and patient rate limiting.\n- Preserves function signature.\n\nInstallation\n------------\n\n.. code-block:: bash\n\n    $ pip install ratelim\n\nUsage\n-----\n\nSay you want to call a function at most for ``n_calls`` during a ``n_seconds`` time interval.\n\n.. code-block:: python\n\n    # 10 times in 5 seconds\n    @ratelim.greedy(10, 5)\n    def hello():\n        print(\"hello\")\n\n\nThe ``greedy`` rate limiter calls does not delay any function call until it's really necessary.\n\nIn some scenarios, for example when crawling data from an API, you want to maximize the number\nof calls you make and you want to avoid sending them in short sequence. To this aim, we can\nuse the ``patient`` rate limiter. It distributes calls evenly between each other.\n\n.. code-block:: python\n\n    # 10 times in 5 seconds\n    # Gets called at most every 0.5 seconds\n    @ratelim.patient(10, 5)\n    def hello():\n        print(\"hello\")\n\nLICENSE\n-------\n\nMIT.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Makes it easy to respect rate limits.",
    "version": "0.1.6",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "dbb786fb8abbbff7f1739cac97188cea",
                "sha256": "e1a7dd39e6b552b7cc7f52169cd66cdb826a1a30198e355d7016012987c9ad08"
            },
            "downloads": -1,
            "filename": "ratelim-0.1.6-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dbb786fb8abbbff7f1739cac97188cea",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 4017,
            "upload_time": "2015-02-27T18:06:06",
            "upload_time_iso_8601": "2015-02-27T18:06:06.464051Z",
            "url": "https://files.pythonhosted.org/packages/f2/98/7e6d147fd16a10a5f821db6e25f192265d6ecca3d82957a4fdd592cad49c/ratelim-0.1.6-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "91063fcac413e9faba01c9046c5134dc",
                "sha256": "826d32177e11f9a12831901c9fda6679fd5bbea3605910820167088f5acbb11d"
            },
            "downloads": -1,
            "filename": "ratelim-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "91063fcac413e9faba01c9046c5134dc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 2793,
            "upload_time": "2015-02-27T18:06:08",
            "upload_time_iso_8601": "2015-02-27T18:06:08.530152Z",
            "url": "https://files.pythonhosted.org/packages/c5/5a/e1440017bccb14523bb76356e6f3a5468386b8a9192bd901e98babd1a1ea/ratelim-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2015-02-27 18:06:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "themiurgo",
    "github_project": "ratelim",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "decorator",
            "specs": [
                [
                    "==",
                    "3.4.0"
                ]
            ]
        }
    ],
    "lcname": "ratelim"
}
        
Elapsed time: 0.03284s