Skip to content

ratelimit.exception.RateLimitException: too many calls #61

Open

Description

@kingwongf

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.

Activity

  1. DanielMistrik commented on Jan 16, 2023

    @DanielMistrik

    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.

  2. SamStephens commented on Mar 29, 2023

    @SamStephens

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions