fastapi-limiter icon indicating copy to clipboard operation
fastapi-limiter copied to clipboard

evalsha() got an unexpected keyword argument 'keys'

Open PaiHsuehChung opened this issue 3 years ago • 9 comments

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

PaiHsuehChung avatar Sep 24 '21 08:09 PaiHsuehChung

Upgrade fastapi-limiter

long2ice avatar Sep 24 '21 08:09 long2ice

Is this issue resolved? Still facing this.

ssinghgc avatar Oct 30 '21 20:10 ssinghgc

@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)

GGGoingdown avatar Nov 01 '21 03:11 GGGoingdown

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 avatar Feb 14 '22 03:02 MarcWarrior

@MarcWarrior fastapi-limiter to v0.1.4 still have this issue, but will fix with your snippets. Can you update this package to pipy

UnknownFX02 avatar Feb 17 '22 10:02 UnknownFX02

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.

charlax avatar Mar 08 '22 17:03 charlax

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 =)

Acendro avatar Mar 10 '22 17:03 Acendro

Yup is relevant to https://github.com/long2ice/fastapi-limiter/issues/20

Is the repo owner no longer maintaining this project?

WardPearce avatar Jun 04 '22 22:06 WardPearce

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
)

python-programmer avatar Oct 14 '22 03:10 python-programmer