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

Library does not wait on request that overflow the bucket with a max_delay argument #175

Open
Sargeanthost opened this issue Jul 14, 2024 · 1 comment

Comments

@Sargeanthost
Copy link

Sargeanthost commented Jul 14, 2024

I want my requests to be sent, not dropped, so I'm trying to use max_delay.

You may want to simply slow down your requests to stay within the rate limits instead of canceling them. In that case you pass the max_delay argument the maximum value of delay (typically in ms when use human-clock).

However, I keep getting this error:

Re-acquiring with delay expected to be successful,
if it failed then either clock or bucket is probably unstable

Why? I've set up a limiter in many different ways, here's one:

self.limiter = Limiter(
            SingleBucketFactory(
                InMemoryBucket([Rate(2, Duration.SECOND)]), MonotonicClock()
            ),
            clock=MonotonicClock(),
            max_delay=999999,
        )

the raise_when_fail vs not is kind of useless, since exception/False is all the same. I expect the library to handle delaying the requests when passed in the parameter, so I'm confused why it's not doing this. Pointers would be useful, thanks

Edit:
It looks like it's limiting when the weight is set to 2 and not 1, is there a reason for this?

@lordscales91
Copy link

lordscales91 commented Aug 5, 2024

From the provided code snippet I see that you are assigning to some class instance. The limiter instance should be the same for all the calls that you want to apply the limit to. See #172

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

2 participants