{ "info": { "author": "Konrad Ja\u0142owiecki ", "author_email": "dexter2206@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "choke: simple implementation of throttling mechanism\n====================================================\n\n|License: MIT| |Build Status|\n\n**choke** is a package implementing a trivial to use general purpose throttling mechanism. The basic workflow with **choke** is as follows:\n\n1. Create manager - an object responsible for keeping track of timestamps when some events (think: calls to your functions) occur.\n2. Instruct manager to \"choke\" some callables, i.e. define maximum number of calls that can occur per given time window.\n3. Use your callables as usual, keeping in mind that when the above defined limit is exceeded, the choked callable will raise `CallLimitExceededError`.\n\nHere is an example containing everything you need to use **choke**:\n\n.. code:: python\n\n from time import sleep\n from redis import StrictRedis\n from choke import RedisChokeManager, CallLimitExceededError\n\n REDIS = StrictRedis() # Tweak this to reflect your setup \n CHOKE_MANAGER = RedisChokeManager(redis=REDIS)\n\n # Example configuration: enforce limit of no more than 10 calls in two seconds window\n @CHOKE_MANAGER.choke(limit=10, window_length=2)\n def foo(x, y):\n \"\"\"Just print something to show that foo was called.\"\"\"\n print(f'foo called with ({x}, {y})')\n\n if __name__ == '__main__':\n # We expect pattern of 10 successes followed by 10 failures followed again by 10 successes\n # Some deviations from this pattern may obviously occur as calling foo takes nonzero time\n for i in range(30):\n try:\n foo(i, y=i ** 2)\n except CallLimitExceededError:\n print('Foo not called. Limit exceeded!')\n sleep(0.1)\n\n\n.. |License: MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg\n :target: https://opensource.org/licenses/MIT\n.. |Build Status| image:: https://travis-ci.org/dexter2206/choke.svg?branch=master\n :target: https://travis-ci.org/dexter2206/choke", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "throttling redis limit", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "choke", "package_url": "https://pypi.org/project/choke/", "platform": "Linux", "project_url": "https://pypi.org/project/choke/", "project_urls": null, "release_url": "https://pypi.org/project/choke/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "choke: simple implementation of throttling mechanism.", "version": "0.1.2" }, "last_serial": 5328446, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "2f25ec3dbcfa079fafebae85ac1bee61", "sha256": "3721be300780efc5b0d1f8567ca8ee7c6c2807e1c03f2455a9e935f331cdecd1" }, "downloads": -1, "filename": "choke-0.1.0.tar.gz", "has_sig": false, "md5_digest": "2f25ec3dbcfa079fafebae85ac1bee61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6922, "upload_time": "2019-03-14T01:54:30", "url": "https://files.pythonhosted.org/packages/55/11/6b4566dbfb7940e65ae729f2631eabd9b16cd783e98390843be985878181/choke-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "0e30eb75cfeecf656fd0916208943171", "sha256": "6b640f6a6e85d88b37afad764db29b0c4a4552956d0f7f38e9a674ef3dedd803" }, "downloads": -1, "filename": "choke-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0e30eb75cfeecf656fd0916208943171", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7064, "upload_time": "2019-05-26T20:36:54", "url": "https://files.pythonhosted.org/packages/90/bb/f4876e218fcc646cc4cf029aa51bda0bd04ee3c6ab4af9042bd42acafad0/choke-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "512d4b8026a965ad0f9c61f3136c10ac", "sha256": "73312fe55de02f838c2b4c2b0f4faae549ef97dbe78efd6e50e5377ac74bf619" }, "downloads": -1, "filename": "choke-0.1.2.tar.gz", "has_sig": false, "md5_digest": "512d4b8026a965ad0f9c61f3136c10ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7054, "upload_time": "2019-05-28T19:02:24", "url": "https://files.pythonhosted.org/packages/10/15/3e465780f8f042a45c636c86efd46288c16a0a5fd6304bf4cfb2c18d98ac/choke-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "512d4b8026a965ad0f9c61f3136c10ac", "sha256": "73312fe55de02f838c2b4c2b0f4faae549ef97dbe78efd6e50e5377ac74bf619" }, "downloads": -1, "filename": "choke-0.1.2.tar.gz", "has_sig": false, "md5_digest": "512d4b8026a965ad0f9c61f3136c10ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7054, "upload_time": "2019-05-28T19:02:24", "url": "https://files.pythonhosted.org/packages/10/15/3e465780f8f042a45c636c86efd46288c16a0a5fd6304bf4cfb2c18d98ac/choke-0.1.2.tar.gz" } ] }