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

ratelimit.exception.RateLimitException: too many calls #61

Open
kingwongf opened this issue Jan 8, 2023 · 2 comments
Open

ratelimit.exception.RateLimitException: too many calls #61

kingwongf opened this issue Jan 8, 2023 · 2 comments

Comments

@kingwongf
Copy link

kingwongf commented Jan 8, 2023

Hi, getting this error and not sure how to interpret it. The whole purpose of using ratelimit is to prevent too many calls?

  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ratelimit/decorators.py", line 77, in wrapper
    raise RateLimitException('too many calls', period_remaining)
ratelimit.exception.RateLimitException: too many calls

I have a simple for loop that calls a function with requests.get in it, which is decorated with @limits(calls=50, period=120) . Would really appreciate some help.

@DanielMistrik
Copy link

DanielMistrik commented Jan 16, 2023

From the code it seems that the ratelimit decorator does prevent too many calls but it does so by throwing the exception it threw you. This means that you tried to call it more than 50 times in 120 seconds so the decorator threw the error and so prevented you from calling the function too many times.

I would recommend some exception catching or async functions but the decorator itself won't just sit silent and not call your function if you go over the rate limit.

@SamStephens
Copy link

@kingwongf I've found that most of the time I'm wanting to combine the @limits decorator with @sleep_and_retry, so when you hit the rate limit, the thread sleeps until the specified time period has elapsed.

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

3 participants