fastapi-limiter
fastapi-limiter copied to clipboard
evalsha() got an unexpected keyword argument 'keys'
HI: Fist of all, I want to appreciate that you build such awesome tool. When i use this library encounter some problem like title, which code write on
File "/usr/local/lib/python3.8/site-packages/fastapi_limiter/depends.py", line 42, in __call__
pexpire = await redis.evalsha(
TypeError: evalsha() got an unexpected keyword argument 'keys'
Environments:
- python 3.8
- aioredis == 2.0.0
- fastapi-limiter==0.1.4
- fastapi==0.68.1
Upgrade fastapi-limiter
Is this issue resolved? Still facing this.
@ssinghgc When i using pip or poetry to install still facing this problem. So you can build from source. It work for me (git+https://github.com/long2ice/fastapi-limiter.git)
Is this issue resolved? Still facing this.
You should upgrade fastapi-limiter to v0.1.4 or modify the original code like this:
rate_key = await identifier(request)
key = f"{FastAPILimiter.prefix}:{rate_key}:{index}"
pexpire = await redis.evalsha(
FastAPILimiter.lua_sha, 1, key, str(self.times), str(self.milliseconds)
)
@MarcWarrior fastapi-limiter to v0.1.4 still have this issue, but will fix with your snippets. Can you update this package to pipy
fastapi-limiter-0.1.4.tar.gz
which is currently on pypi still has keys
keyword argument. Can you push a new version?
Btw, https://github.com/aio-libs/aioredis-py is being merged into redis-py
.
I just came around the same issue and discovered a workaround that some of you might find helpful. You can basically install the 1.0.6 version with: 'pip install https://github.com/hardbyte/fastapi-limiter/archive/patch-1.zip' And in your requirements.txt just swap out the 'fastapi-limiter==xxx' to 'git+https://github.com/hardbyte/fastapi-limiter@patch-1'
Runs like a charm for me now =)
Yup is relevant to https://github.com/long2ice/fastapi-limiter/issues/20
Is the repo owner no longer maintaining this project?
check your aioredis version, this version(fastapi-limiter on pypi == 0.1.4) doesn't work with aioredis >= 2.0
for version 2.0 and above, I think the maintainer must change the below code:
pexpire = await redis.evalsha(
FastAPILimiter.lua_sha, keys=[key], args=[self.times, self.milliseconds]
)
TO
keys = [key]
pexpire = await redis.evalsha(
FastAPILimiter.lua_sha, len(keys), *keys, self.times, self.milliseconds
)