Open phillipuniverse opened 4 months ago
My problem also feels very similar to https://github.com/vutran1710/PyrateLimiter/issues/128
I see your point, but right now i'm quite busy with company stuff so this has to wait.
Thanks @vutran1710, appreciate the work you put into this library!
My guess is that the resolution of https://github.com/vutran1710/PyrateLimiter/issues/160 would also fix my issues, seems pretty similar to what I'm seeing.
Also, I updated the test case to make it easier to reproduce by removing all the Django pieces.
I'm trying to understand how I need to use / re-use
Limiter
instances and I'm not quite understanding the behavior. I wrote a little sample multithreading script to evaluate the behavior.I'm using version 3.6.1.
I'm using Django but it shouldn't be that material to what's going on.
Here's my code:
It does not appear that this is rate limited correctly. Here is some of the logging I'm getting:
Doing some light debugging it appears that the threads are going to sleep as they get rate limited and then when they wake back up they expect to grab the item from the bucket but can't.
If I set the
Limiter
as a module level variable then things seem to get rate limited, it's a chunky 3 requests per second:Output:
My goal is to understand how this code will behave across a cluster. My design is to have many containers that are all trying to contend with hitting the same external API, but that external API has a rate limit. I would like workers to sleep when they are rate limited until they can make the API call