{"id":28112,"library":"python-redis-rate-limit","title":"Python Redis Rate Limit","description":"A Python rate limiter based on Redis using a sliding window algorithm. It provides a decorator and context manager to limit the rate of function calls or code blocks. Version 0.0.10 is the latest release, with no recent updates; the package appears to be in maintenance mode.","status":"maintenance","version":"0.0.10","language":"python","source_language":"en","source_url":"https://github.com/evoluxbr/python-redis-rate-limit","tags":["rate-limiting","redis","decorator","context-manager"],"install":[{"cmd":"pip install python-redis-rate-limit","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Required for Redis connection","package":"redis","optional":false}],"imports":[{"note":null,"wrong":null,"symbol":"rate_limit","correct":"from rate_limit import rate_limit"}],"quickstart":{"code":"import redis\nfrom rate_limit import rate_limit\n\nr = redis.Redis(host='localhost', port=6379, db=0)\n\n@rate_limit(r, max_calls=10, period=60)\ndef my_function():\n    print('Function called')\n\nfor _ in range(12):\n    my_function()","lang":"python","description":"Basic usage of the rate_limit decorator, limiting to 10 calls per 60 seconds."},"warnings":[{"fix":"Wrap decorated calls in try-except or implement a fallback mechanism (e.g., check Redis availability before decorating).","message":"The rate_limit decorator uses a sliding window, but requires a Redis instance. If Redis is down, the decorator will raise redis.exceptions.ConnectionError. The library does not handle connection failures gracefully.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3 and use v0.0.9 or later.","message":"In v0.0.9, deprecated distutils.version was removed. This may affect users relying on Python 2.7 support (which was also removed). The library now requires Python 3.","severity":"deprecated","affected_versions":">=0.0.9"},{"fix":"Instantiate a new rate limiter object locally or ensure only one Redis instance is used. Check the source code for details.","message":"The package uses a global redis client reference; if multiple decorators or context managers are used with different Redis instances, the wrong instance may be used due to how the library stores the connection internally.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install the package and import correctly: `from rate_limit import rate_limit`. The module name is 'rate_limit' (not 'python_redis_rate_limit').","cause":"Trying to import rate_limit incorrectly (e.g., 'from python_redis_rate_limit import rate_limit' or 'import rate_limit') without understanding the package structure.","error":"ModuleNotFoundError: No module named 'rate_limit'"},{"fix":"Start the Redis server: `redis-server`. Alternatively, use environment variables to configure the connection, e.g., `redis.Redis.from_url(os.environ.get('REDIS_URL', 'redis://localhost:6379'))`.","cause":"Redis server is not running or not accessible at the specified host/port.","error":"redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}