{"id":17087148,"url":"https://github.com/soulomoon/python-throttle","last_synced_at":"2025-06-12T22:32:57.616Z","repository":{"id":57457632,"uuid":"124670645","full_name":"soulomoon/python-throttle","owner":"soulomoon","description":"Super naive python redis limiter","archived":false,"fork":false,"pushed_at":"2021-11-20T08:23:36.000Z","size":55,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-26T16:03:20.307Z","etag":null,"topics":["limiter","python","redis","throttle"],"latest_commit_sha":null,"homepage":"https://github.com/soulomoon/python-throttle","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soulomoon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-10T15:53:07.000Z","updated_at":"2023-07-16T14:06:13.000Z","dependencies_parsed_at":"2022-09-07T01:13:17.692Z","dependency_job_id":null,"html_url":"https://github.com/soulomoon/python-throttle","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulomoon%2Fpython-throttle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulomoon%2Fpython-throttle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulomoon%2Fpython-throttle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soulomoon%2Fpython-throttle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soulomoon","download_url":"https://codeload.github.com/soulomoon/python-throttle/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637834,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["limiter","python","redis","throttle"],"created_at":"2024-10-14T13:31:14.063Z","updated_at":"2025-04-12T21:53:10.548Z","avatar_url":"https://github.com/soulomoon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![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    \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\nReset the limiter: \n```\nthrottle.reset()\n```\n\n## dummy benchmark\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```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulomoon%2Fpython-throttle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoulomoon%2Fpython-throttle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoulomoon%2Fpython-throttle/lists"}