{ "info": { "author": "soulomoon", "author_email": "fwy996602672@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "[![python version](https://img.shields.io/pypi/pyversions/python-throttle.svg)](https://pypi.python.org/pypi/python-throttle)\n![Build Status](https://travis-ci.org/soulomoon/python-throttle.svg?branch=develop)\n[![codecov](https://codecov.io/gh/soulomoon/python-throttle/branch/develop/graph/badge.svg)](https://codecov.io/gh/soulomoon/python-throttle)\n[![PyPI version](https://badge.fury.io/py/python-throttle.svg)](https://badge.fury.io/py/python-throttle)\n\n\n# python redis backed limiter\n\n## sliding log or fixed window limiter\nThis module mainly offer two limiter\n* FixedWindowLimiter \nsimply using redis incr, which about 10 times the speed of the sliding version but the limit is not smooth, may overflow a threshold size near the gap between two intervals\n* SlidingWindowLimiter \u00a0 \nusing redis ordered set, slow but offers more smooth limit and more extendability\n\n## installation\n`pip install python-throttle`\n\n## dummy example usage:\nreminder: use name_space to avoid possible conflict on the same key\n```python\nimport time\nfrom limiter import FixedWindowLimiter\nTEST_REDIS_CONFIG = {'host': 'localhost','port': 6379,'db': 10}\nip = \"who are you?\"\nthrottle = FixedWindowLimiter(threshold=2, interval=3, redis_config=TEST_REDIS_CONFIG, name_space=\"default\")\nprint(\"first time, blocked?: {}\".format(throttle.exceeded(ip)))\nprint(\"second time, blocked?: {}\".format(throttle.exceeded(ip)))\nprint(\"now I block you, blocked?: {}\".format(throttle.exceeded(ip)))\ntime.sleep(3)\nprint(\"refill energy, blocked?: {}\".format(throttle.exceeded(ip)))\n```\nouput:\n```\nfirst time blocked?: False\nsecond time blocked?: False\nnow I block you blocked?: True\nrefill energy blocked?: False\n```\n\n## dummy beach mark\nIt is from my unittest and not accurate,\n```\nrate_counter_pressure_test: SlidingRedisCounter\nrate_counter_pressure_test: SlidingRedisCounter time count: 1.0075314449495636\nrate_counter_pressure_test: FixedWindowRedisCounter\nrate_counter_pressure_test: FixedWindowRedisCounter time count: 0.13711917598266155\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/soulomoon/python-throttle", "keywords": "throttle limiter redis counter timer middleware", "license": "", "maintainer": "", "maintainer_email": "", "name": "python-throttle", "package_url": "https://pypi.org/project/python-throttle/", "platform": "", "project_url": "https://pypi.org/project/python-throttle/", "project_urls": { "Homepage": "https://github.com/soulomoon/python-throttle" }, "release_url": "https://pypi.org/project/python-throttle/0.2.0/", "requires_dist": null, "requires_python": ">=3.5", "summary": "Super naive python redis limiter", "version": "0.2.0" }, "last_serial": 5375412, "releases": { "0.1.3": [ { "comment_text": "", "digests": { "md5": "265e34f7c7276907a1c63fe5f56dc279", "sha256": "272b552e729971f4eb534983c47927e10626144c1d98e079b2c87ccea92bcf9b" }, "downloads": -1, "filename": "python-throttle-0.1.3.tar.gz", "has_sig": false, "md5_digest": "265e34f7c7276907a1c63fe5f56dc279", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4506, "upload_time": "2018-03-19T15:21:24", "url": "https://files.pythonhosted.org/packages/3a/58/bf3d77b8172722e2b3946ee4f913dc5dc32e9a0f33c8349b79834cb8ddae/python-throttle-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "011a3ebc7e863486ce0bef0cd83dc2f0", "sha256": "e127b90947dde2d3415f4289b83fa95b8828d23ea9c92a5325f11b220387b38a" }, "downloads": -1, "filename": "python-throttle-0.1.4.tar.gz", "has_sig": false, "md5_digest": "011a3ebc7e863486ce0bef0cd83dc2f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4541, "upload_time": "2018-03-20T07:09:54", "url": "https://files.pythonhosted.org/packages/a4/97/c4db4ac6146db4de0f21d1f9c2a9022b98952268a3a539cb0e331474407a/python-throttle-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "326ae959036f10ecf696ea39628172db", "sha256": "17a67e80818983b0a845227082da546f2f0bde3a188f3c42985995dac3fba387" }, "downloads": -1, "filename": "python-throttle-0.1.5.tar.gz", "has_sig": false, "md5_digest": "326ae959036f10ecf696ea39628172db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4917, "upload_time": "2018-03-20T07:59:35", "url": "https://files.pythonhosted.org/packages/3a/9e/749a67ed9e949ae45e3be95ab09c663b82e63e03c37473f07a332a9af6e5/python-throttle-0.1.5.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "60638b416d70c220470155fa416f29e1", "sha256": "c737bdf141fc2141532a0a78b1d61b826d1478d46dba9ae5c9b4d962f3e0b655" }, "downloads": -1, "filename": "python-throttle-0.1.6.tar.gz", "has_sig": false, "md5_digest": "60638b416d70c220470155fa416f29e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4972, "upload_time": "2018-06-12T05:14:56", "url": "https://files.pythonhosted.org/packages/02/6c/a48a9fbd54740e025a01de12ec7f099d84aef0881b6f83a4c2a3a12cd499/python-throttle-0.1.6.tar.gz" } ], "0.1.8": [ { "comment_text": "", "digests": { "md5": "2f0fbd4bd268c9bd2a3974c13c696cf9", "sha256": "c8fcd81465b8c67e376eb8a920dc4c024c40e0d753670eb883357c0047ae6e45" }, "downloads": -1, "filename": "python-throttle-0.1.8.tar.gz", "has_sig": false, "md5_digest": "2f0fbd4bd268c9bd2a3974c13c696cf9", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 4982, "upload_time": "2019-06-08T13:10:36", "url": "https://files.pythonhosted.org/packages/d5/72/4c744460ce30404b2b68a6c965a771d09f4566aea2e1754e97919eab26d4/python-throttle-0.1.8.tar.gz" } ], "0.1.9": [ { "comment_text": "", "digests": { "md5": "9dbd85583e656c855dac71ecdc4bbcdf", "sha256": "a7d6300a0f0514b3444bc9033de239d1ba6bd54ac711b8d5b64dc35b56848c2d" }, "downloads": -1, "filename": "python-throttle-0.1.9.tar.gz", "has_sig": false, "md5_digest": "9dbd85583e656c855dac71ecdc4bbcdf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 4978, "upload_time": "2019-06-08T13:25:03", "url": "https://files.pythonhosted.org/packages/b4/a9/629e8c88cb54bdd3afb81b6109c4b3e29cc1918058f2a9a5c9d26c1ccaf4/python-throttle-0.1.9.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "edf77f9ffd0ffc773c1f5da996127a6b", "sha256": "9fe5016cf0b5db6884b02e9f6923cb6d4864c477af8b751daa3bd686debbff4e" }, "downloads": -1, "filename": "python-throttle-0.2.0.tar.gz", "has_sig": false, "md5_digest": "edf77f9ffd0ffc773c1f5da996127a6b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 4879, "upload_time": "2019-06-08T13:36:24", "url": "https://files.pythonhosted.org/packages/13/72/f6a7ef6cc6c1450c132ff25796ab6240f223b3fb797866cbf8c26f721aa2/python-throttle-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "edf77f9ffd0ffc773c1f5da996127a6b", "sha256": "9fe5016cf0b5db6884b02e9f6923cb6d4864c477af8b751daa3bd686debbff4e" }, "downloads": -1, "filename": "python-throttle-0.2.0.tar.gz", "has_sig": false, "md5_digest": "edf77f9ffd0ffc773c1f5da996127a6b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 4879, "upload_time": "2019-06-08T13:36:24", "url": "https://files.pythonhosted.org/packages/13/72/f6a7ef6cc6c1450c132ff25796ab6240f223b3fb797866cbf8c26f721aa2/python-throttle-0.2.0.tar.gz" } ] }