long2ice / fastapi-limiter

A request rate limiter for fastapi
https://github.com/long2ice/fastapi-limiter
Apache License 2.0
507 stars 55 forks source link

Bug with latest version #16

Open hardbyte opened 3 years ago

hardbyte commented 3 years ago

Creating a new project with latest versions of fastapi and fastapi-limiter runs into an issue:

TypeError: evalsha() got an unexpected keyword argument 'keys'

I used the following test code:

import aioredis
from fastapi import Depends, FastAPI

from fastapi_limiter import FastAPILimiter
from fastapi_limiter.depends import RateLimiter

app = FastAPI()

@app.on_event("startup")
async def startup():
    redis = await aioredis.from_url("redis://localhost", encoding="utf-8", decode_responses=True)
    await FastAPILimiter.init(redis)

@app.get("/", dependencies=[Depends(RateLimiter(times=2, seconds=5))])
async def index():
    return {"message": "Hello World"}
marvingabler commented 3 years ago

Commit is great, please merge this one! Thank you so much!

divadsn commented 2 years ago

Can't really reproduce that one, using latest aioredis and Python 3.10 everything works fine on 0.1.5 :thinking:

Edit: That bug is on 0.1.4, which is using aioredis 1.3.1, while the repo is already on aioredis 2.0.0

hardbyte commented 2 years ago

https://pypi.org/project/fastapi-limiter/#history

divadsn commented 2 years ago

@hardbyte and? The latest version in the repo is 0.1.5, which is updated to use aioredis 2.0.0 and works totally fine, just use that until @long2ice eventually pushes that one to PyPi.

https://github.com/long2ice/fastapi-limiter/pull/17#issuecomment-1088301326