Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limits more than specified #52

Open
mandarup opened this issue Jun 4, 2021 · 4 comments
Open

limits more than specified #52

mandarup opened this issue Jun 4, 2021 · 4 comments

Comments

@mandarup
Copy link

mandarup commented Jun 4, 2021

for some reason, I get half the rate specified.
e.g 2/minute -> 1, 10/minute -> 5

This is my set up:

from fastapi import FastAPI, Request
from slowapi import Limiter, _rate_limit_exceeded_handler
from slowapi.util import get_remote_address
from slowapi.errors import RateLimitExceeded

limiter = Limiter(key_func=get_remote_address)
app = FastAPI()
app.state.limiter = limiter
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)


@app.get("/")
@limiter.limit("5/minute")
async def root(request: Request):
    return {"message": "Hello World"}

Is there anything obvious that I might be missing here?

@danielqba
Copy link

Hey, I know it is really a long time ago, but are you still having this issue?

@samvr-pxl
Copy link

I'm still having this issue as well. But it's not always reproducible. I thought it had to do with the --reload flag for setting up fastapi, but that was not it.

@thentgesMindee
Copy link
Collaborator

Hello @samvr-pxl could you also share how you run your server ? is it a development server ? using uvicorn ?
That could help us find the reason

@samvr-pxl
Copy link

I'm sorry for not responding earlier. I had not seen your reply.
Not sure if it's relevant anymore.

But I noticed it when setting up a fastai server with these commands:
uvicorn main:app --proxy-headers --host 0.0.0.0 --port 80 --reload
and
uvicorn main:app --proxy-headers --host 0.0.0.0 --port 80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants