{ "info": { "author": "Frazer McLean", "author_email": "frazer@frazermclean.co.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License" ], "description": "RateLimiter\n===========\n\n|PyPI Version| |Build Status| |Python Version| |License|\n\nSimple Python module providing rate limiting.\n\nOverview\n--------\n\nThis package provides the ``ratelimiter`` module, which ensures that an\noperation will not be executed more than a given number of times on a\ngiven period. This can prove useful when working with third parties APIs\nwhich require for example a maximum of 10 requests per second.\n\nUsage\n-----\n\nDecorator\n~~~~~~~~~\n\n.. code:: python\n\n from ratelimiter import RateLimiter\n\n @RateLimiter(max_calls=10, period=1)\n def do_something():\n pass\n\nContext Manager\n~~~~~~~~~~~~~~~\n\n.. code:: python\n\n from ratelimiter import RateLimiter\n\n rate_limiter = RateLimiter(max_calls=10, period=1)\n\n for i in range(100):\n with rate_limiter:\n do_something()\n\nCallback\n~~~~~~~~\n\nThe callback is called in its own thread, so your callback may use\n``sleep`` without delaying the rate limiter.\n\n.. code:: python\n\n import time\n\n from ratelimiter import RateLimiter\n\n def limited(until):\n duration = int(round(until - time.time()))\n print('Rate limited, sleeping for {:d} seconds'.format(duration))\n\n rate_limiter = RateLimiter(max_calls=2, period=3, callback=limited)\n\n for i in range(3):\n with rate_limiter:\n print('Iteration', i)\n\nOutput:\n\n::\n\n Iteration 0\n Iteration 1\n Rate limited, sleeping for 3 seconds\n Iteration 2\n\nasyncio\n~~~~~~~\n\nThe ``RateLimiter`` object can be used in an ``async with`` statement on\nPython 3.5+. Note that the callback must be a coroutine in this context.\nThe coroutine callback is not called in a separate thread.\n\n.. code:: python\n\n import asyncio\n import time\n\n from ratelimiter import RateLimiter\n\n async def limited(until):\n duration = int(round(until - time.time()))\n print('Rate limited, sleeping for {:d} seconds'.format(duration))\n\n async def coro():\n rate_limiter = RateLimiter(max_calls=2, period=3, callback=limited)\n for i in range(3):\n async with rate_limiter:\n print('Iteration', i)\n\n loop = asyncio.get_event_loop()\n loop.run_until_complete(coro())\n\nLicense\n-------\n\n| Original work Copyright 2013 Arnaud Porterie\n| Modified work Copyright 2016 Frazer McLean\n\nLicensed under the Apache License, Version 2.0 (the \u201cLicense\u201d); you may\nnot use this file except in compliance with the License. You may obtain\na copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \u201cAS IS\u201d BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n.. |PyPI Version| image:: http://img.shields.io/pypi/v/ratelimiter.svg?style=flat-square\n :target: https://pypi.python.org/pypi/ratelimiter\n.. |Build Status| image:: http://img.shields.io/travis/RazerM/ratelimiter/master.svg?style=flat-square\n :target: https://travis-ci.org/RazerM/ratelimiter\n.. |Python Version| image:: https://img.shields.io/badge/python-2.7%2C%203-brightgreen.svg?style=flat-square\n :target: https://www.python.org/downloads/\n.. |License| image:: http://img.shields.io/badge/license-Apache-blue.svg?style=flat-square\n :target: https://github.com/RazerM/ratelimiter/blob/master/LICENSE\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/RazerM/ratelimiter", "keywords": "", "license": "Apache", "maintainer": "", "maintainer_email": "", "name": "ratelimiter", "package_url": "https://pypi.org/project/ratelimiter/", "platform": "", "project_url": "https://pypi.org/project/ratelimiter/", "project_urls": { "Homepage": "https://github.com/RazerM/ratelimiter" }, "release_url": "https://pypi.org/project/ratelimiter/1.2.0.post0/", "requires_dist": [ "pytest (>=3.0); extra == 'test'", "pytest-asyncio; python_version>=\"3.5\" and extra == 'test'" ], "requires_python": "", "summary": "Simple python rate limiting object", "version": "1.2.0.post0" }, "last_serial": 3408975, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "f819e8ea8797155726bbac5d767cb2e7", "sha256": "5f0b1b18a6a7943725c79fb2fd8662b0139068d1854f37c03be4004b15e24273" }, "downloads": -1, "filename": "ratelimiter-0.2.1-py2.7.egg", "has_sig": false, "md5_digest": "f819e8ea8797155726bbac5d767cb2e7", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 5052, "upload_time": "2015-01-20T00:36:48", "url": "https://files.pythonhosted.org/packages/fb/c4/941c8ca74ba011b08a127101ae9aeb88b6b3aedbd796fcb25fff1a381368/ratelimiter-0.2.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "bc6442a6f99d13f861c764eaa18e5d90", "sha256": "b69987ab6b31ee2b04719b48939eac5a0d50972175eda32ed48e7192af83300a" }, "downloads": -1, "filename": "ratelimiter-0.2.1.tar.gz", "has_sig": false, "md5_digest": "bc6442a6f99d13f861c764eaa18e5d90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3025, "upload_time": "2015-01-20T00:36:50", "url": "https://files.pythonhosted.org/packages/c4/54/ee8d93c3a7687e44b6b29377ad91c7143d7b583174da5bb5f324f6a2163e/ratelimiter-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "2303706e84ffcaa095639846b5d000c5", "sha256": "97591bf1a606f4c522b38db7e5ea95b0fdae547001e472c68a1e6858f5954af1" }, "downloads": -1, "filename": "ratelimiter-0.2.2.tar.gz", "has_sig": false, "md5_digest": "2303706e84ffcaa095639846b5d000c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3012, "upload_time": "2015-01-20T00:40:23", "url": "https://files.pythonhosted.org/packages/06/24/d987fa08fb42167a814359cb6eb0f34ba2633c9f713e8289fb5b42b5adb4/ratelimiter-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "ddd4c04abe81ed48bb4614587001305c", "sha256": "6da8c74618222205f7198488b37e4caab2d7b10e3543cbe5b0c619e56800df4e" }, "downloads": -1, "filename": "ratelimiter-0.2.3.tar.gz", "has_sig": false, "md5_digest": "ddd4c04abe81ed48bb4614587001305c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3814, "upload_time": "2015-01-20T01:07:53", "url": "https://files.pythonhosted.org/packages/e5/7c/66ba31b3b4b2641240b6012e04d67a0d247c4d67fae9141eef04f08a4b29/ratelimiter-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "93b5f8d16ee6b0ac1285d2a26e63e5b0", "sha256": "579ed7e3248ba6d2f874f83ab7522ec44bef303ab34a16b36896f6fe2d639b0b" }, "downloads": -1, "filename": "ratelimiter-0.2.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "93b5f8d16ee6b0ac1285d2a26e63e5b0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6712, "upload_time": "2015-11-27T15:44:03", "url": "https://files.pythonhosted.org/packages/3f/94/fe7589c06e2ea7930db69d7fa4804b414acafbb68c869b1e67d07ef19e67/ratelimiter-0.2.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1af0af5676aeb7b7753ad47ddd908d1e", "sha256": "a9331f800115bab587582cd63fffb0c079407cd349e9a1d4a864971f1348decd" }, "downloads": -1, "filename": "ratelimiter-0.2.4.zip", "has_sig": false, "md5_digest": "1af0af5676aeb7b7753ad47ddd908d1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8422, "upload_time": "2015-11-27T15:44:21", "url": "https://files.pythonhosted.org/packages/16/44/c62ad8f5aec2dad3c39b8be134c2b3316ce550757139b55d996e3e54b76d/ratelimiter-0.2.4.zip" } ], "0.3.0": [], "1.0.0": [ { "comment_text": "", "digests": { "md5": "74a701b543a204891f7f4fbc085ce5fa", "sha256": "f986c45f7a3385adab39ca2a38e3423933eea81ff2101aeab5476aa449256566" }, "downloads": -1, "filename": "ratelimiter-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "74a701b543a204891f7f4fbc085ce5fa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7669, "upload_time": "2016-01-06T02:28:47", "url": "https://files.pythonhosted.org/packages/09/3a/275830623e776bdcc187e4b3508339add05bcee9c105ba7506003e134e01/ratelimiter-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "faba0542ad2e05159b34860849cce1b2", "sha256": "ec7e6b04b1f6e18024d79ea0ec8965f3b7d182dcaff25de255dcecf9f9e670f7" }, "downloads": -1, "filename": "ratelimiter-1.0.0.tar.gz", "has_sig": false, "md5_digest": "faba0542ad2e05159b34860849cce1b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4559, "upload_time": "2016-01-06T02:28:57", "url": "https://files.pythonhosted.org/packages/3c/ce/024c23e48c57d16070e7b57bb97791655849d19decac2c43910065046517/ratelimiter-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c48821c0848d776353023d7fcf4dcf95", "sha256": "75a21711455ef9908702e9123049e45e95aefd0a6117cd43973d55a0edd50a03" }, "downloads": -1, "filename": "ratelimiter-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c48821c0848d776353023d7fcf4dcf95", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7680, "upload_time": "2016-01-06T04:08:27", "url": "https://files.pythonhosted.org/packages/a6/06/5a11478db858734c7694ab2a94d1dc0f2cf8efa3c3ade69ca2bbcb8b9bcf/ratelimiter-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3c098b301e2fcbf1df379874e3fda713", "sha256": "4c375759b326e99b7b96ecaae62826d1c37f285517ff0587399a67fc8deec474" }, "downloads": -1, "filename": "ratelimiter-1.0.1.tar.gz", "has_sig": false, "md5_digest": "3c098b301e2fcbf1df379874e3fda713", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4577, "upload_time": "2016-01-06T04:08:51", "url": "https://files.pythonhosted.org/packages/6a/3c/4f2d902e0f7c50c72b6049fbb13fd58dcb402df6cb30c32469d8eb750bf0/ratelimiter-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "0de1e369bd6d58a0dfe34a31bee6c0a5", "sha256": "216022befa19998113aa2279dd837b6cca3e0bf30a466a54deafbbbc1d848166" }, "downloads": -1, "filename": "ratelimiter-1.0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "0de1e369bd6d58a0dfe34a31bee6c0a5", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12797, "upload_time": "2016-03-01T18:12:28", "url": "https://files.pythonhosted.org/packages/a0/7e/b107916602f0b7757535956e9fd63f53b91920d4a1f85fd8f8e7f3034b3c/ratelimiter-1.0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "458738fc01c52e49958716ae74f9ba81", "sha256": "2e6dcb33a80420a4a7c6934d0a3bb412de2d6ee4053493f22062ecf4484770e8" }, "downloads": -1, "filename": "ratelimiter-1.0.2.tar.gz", "has_sig": false, "md5_digest": "458738fc01c52e49958716ae74f9ba81", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4893, "upload_time": "2016-03-01T18:12:22", "url": "https://files.pythonhosted.org/packages/69/ac/0d06c8c88a49f3487010c2c10e2050d59b838d1214ddeeb6a22f12cb4de2/ratelimiter-1.0.2.tar.gz" } ], "1.0.2.post0": [ { "comment_text": "", "digests": { "md5": "310608ada681b603016cf356987b1488", "sha256": "28d4a60ec0b78a1db034ed4b4fc9649bb659a4b0887e4b61052d13dbaaea6552" }, "downloads": -1, "filename": "ratelimiter-1.0.2.post0-py2.7.egg", "has_sig": false, "md5_digest": "310608ada681b603016cf356987b1488", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 11016, "upload_time": "2016-03-01T19:43:19", "url": "https://files.pythonhosted.org/packages/14/f6/773bcce59e4e47498831e463128fae5c479c9d33e6425a0da5b490f4074a/ratelimiter-1.0.2.post0-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "7d8550e71f3a38840766331dabab5b6d", "sha256": "4c6352ba4ccd44b102d5cff5100e37a378b797a512cc9b73f6c2aaae3cd3a6e1" }, "downloads": -1, "filename": "ratelimiter-1.0.2.post0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7d8550e71f3a38840766331dabab5b6d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7811, "upload_time": "2016-03-01T19:43:08", "url": "https://files.pythonhosted.org/packages/35/53/8c2b0af99971f19428403fddef3820270806e119f301b58a5a4970472200/ratelimiter-1.0.2.post0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8e5bddb9cb530a8709e61c6c3acced9", "sha256": "d852b2018a65a932ae4b28ed3812900bb19912c034b07ff1daf8f12c4b54a5a3" }, "downloads": -1, "filename": "ratelimiter-1.0.2.post0.tar.gz", "has_sig": false, "md5_digest": "f8e5bddb9cb530a8709e61c6c3acced9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4635, "upload_time": "2016-03-01T19:43:28", "url": "https://files.pythonhosted.org/packages/a6/97/d572a35c320da07f178ad4a1f3e97962a8b94f84138f1eac19a28e16b4bf/ratelimiter-1.0.2.post0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "3ad597e6450a9acab75e609d5de1af4f", "sha256": "52af476c896331a14b757eb019a7f04316c204a024a3cc543d898384513b0065" }, "downloads": -1, "filename": "ratelimiter-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3ad597e6450a9acab75e609d5de1af4f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8051, "upload_time": "2017-02-02T00:11:43", "url": "https://files.pythonhosted.org/packages/07/d5/5e3b962984bb48ad82b77a961987ce5c6bae186324ab675f3c2d583abbb3/ratelimiter-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b1b06e58c93ae829fcd49d1b7cda4359", "sha256": "2a4dac0fce314425499a31ef53b93c5bbd2f64e6f11c9b8195a9698e63802edd" }, "downloads": -1, "filename": "ratelimiter-1.1.0.tar.gz", "has_sig": false, "md5_digest": "b1b06e58c93ae829fcd49d1b7cda4359", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4873, "upload_time": "2017-02-02T00:11:44", "url": "https://files.pythonhosted.org/packages/d4/22/36a5994a4e80b25920fdbb06e41bb530e5a281f893561df010ab59de1e24/ratelimiter-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "964904236c0e882c9188e14b6002b222", "sha256": "6e65953a107a08d5ebb513286305db8ed2999bba2694ffc7fcd9a74cd9d19912" }, "downloads": -1, "filename": "ratelimiter-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "964904236c0e882c9188e14b6002b222", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6304, "upload_time": "2017-03-11T01:00:58", "url": "https://files.pythonhosted.org/packages/b5/9b/5075a16533f23caea0bb76bacb8e52c6ac7a13f89adaf2731bf46a4c2ab0/ratelimiter-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f4d07e2934ea62b1429b833f1866674e", "sha256": "5f8388aac3d0fa62d0c3c8cee378a440aa6c45b80c9ebf707d6d770f72b4ca1c" }, "downloads": -1, "filename": "ratelimiter-1.1.1.tar.gz", "has_sig": false, "md5_digest": "f4d07e2934ea62b1429b833f1866674e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4837, "upload_time": "2017-03-11T01:00:59", "url": "https://files.pythonhosted.org/packages/22/9f/98078f47e8fa29c83b1b7b3e8fe514daaa2e4c55fa69d49f70560d45cf12/ratelimiter-1.1.1.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "823f78bb03f2a2e5182972b35ef0294a", "sha256": "d22d933016b803df8c08e6532b9b84678bf4557164d611a4817db9e5434fcd72" }, "downloads": -1, "filename": "ratelimiter-1.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "823f78bb03f2a2e5182972b35ef0294a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6529, "upload_time": "2017-06-17T20:10:43", "url": "https://files.pythonhosted.org/packages/07/7d/694367fef0d90dffd5e5b98ee429f2b7cb3c174b0cb6f969fe5903aec882/ratelimiter-1.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d5b1005e39da11767d2f74b9fc1b666c", "sha256": "f724b256264afdeab0225ec174728b0f8af1afd1cc122463150daf226b411fb6" }, "downloads": -1, "filename": "ratelimiter-1.2.0.tar.gz", "has_sig": false, "md5_digest": "d5b1005e39da11767d2f74b9fc1b666c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4189, "upload_time": "2017-06-17T20:10:44", "url": "https://files.pythonhosted.org/packages/29/92/20d7b661892a19680887fdd2c410a4e3bd51c90a1940dd406e46072ceb94/ratelimiter-1.2.0.tar.gz" } ], "1.2.0.post0": [ { "comment_text": "", "digests": { "md5": "1dabe725652d50c53d794263b46c4e28", "sha256": "a52be07bc0bb0b3674b4b304550f10c769bbb00fead3072e035904474259809f" }, "downloads": -1, "filename": "ratelimiter-1.2.0.post0-py3-none-any.whl", "has_sig": false, "md5_digest": "1dabe725652d50c53d794263b46c4e28", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6642, "upload_time": "2017-12-12T00:33:37", "url": "https://files.pythonhosted.org/packages/51/80/2164fa1e863ad52cc8d870855fba0fbb51edd943edffd516d54b5f6f8ff8/ratelimiter-1.2.0.post0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e677cb4049c85d880b6705b84603820", "sha256": "5c395dcabdbbde2e5178ef3f89b568a3066454a6ddc223b76473dac22f89b4f7" }, "downloads": -1, "filename": "ratelimiter-1.2.0.post0.tar.gz", "has_sig": false, "md5_digest": "5e677cb4049c85d880b6705b84603820", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9182, "upload_time": "2017-12-12T00:33:38", "url": "https://files.pythonhosted.org/packages/5b/e0/b36010bddcf91444ff51179c076e4a09c513674a56758d7cfea4f6520e29/ratelimiter-1.2.0.post0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1dabe725652d50c53d794263b46c4e28", "sha256": "a52be07bc0bb0b3674b4b304550f10c769bbb00fead3072e035904474259809f" }, "downloads": -1, "filename": "ratelimiter-1.2.0.post0-py3-none-any.whl", "has_sig": false, "md5_digest": "1dabe725652d50c53d794263b46c4e28", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6642, "upload_time": "2017-12-12T00:33:37", "url": "https://files.pythonhosted.org/packages/51/80/2164fa1e863ad52cc8d870855fba0fbb51edd943edffd516d54b5f6f8ff8/ratelimiter-1.2.0.post0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e677cb4049c85d880b6705b84603820", "sha256": "5c395dcabdbbde2e5178ef3f89b568a3066454a6ddc223b76473dac22f89b4f7" }, "downloads": -1, "filename": "ratelimiter-1.2.0.post0.tar.gz", "has_sig": false, "md5_digest": "5e677cb4049c85d880b6705b84603820", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9182, "upload_time": "2017-12-12T00:33:38", "url": "https://files.pythonhosted.org/packages/5b/e0/b36010bddcf91444ff51179c076e4a09c513674a56758d7cfea4f6520e29/ratelimiter-1.2.0.post0.tar.gz" } ] }