Skip to content

InMemoryBucket with different user-ids in try_acquire #238

@HaveSec

Description

@HaveSec

Hi,

I have the following code:

rate = Rate(1, Duration.SECOND * 5)
bucket = InMemoryBucket([rate])
limiter = Limiter(bucket, raise_when_fail=True, max_delay=505)

limiter.try_acquire("user_1") # user_1
print("user_1")
limiter.try_acquire("user_2") # user_2
print("user_2")

I would expect, that the two try_acquire will run without problem, because is use different ids in try_acquire(). But I got the following output:

pyrate_limiter.exceptions.LimiterDelayException:
Actual delay exceeded allowance: actual=5050, allowed=505
Bucket for user_2 with Rate limit=1/5.0s is already full

It looks like user_1 and user_2 use the same bucket. I thought the should use different buckets.

pyrate-limiter==3.9.0
Python 3.12.10 on Windows 11

Thank you

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