pyrate_limiter.abstracts.wrappers module#

Wrappers over different abstract types

class pyrate_limiter.abstracts.wrappers.BucketAsyncWrapper(bucket)#

Bases: pyrate_limiter.abstracts.bucket.AbstractBucket

BucketAsyncWrapper is a wrapping over any bucket that turns a async/synchronous bucket into an async one

async count()#

Count number of items in the bucket

property failing_rate#
async flush()#

Flush the whole bucket - Must remove failing-rate after flushing

Return type

None

async leak(current_timestamp=None)#

leaking bucket - removing items that are outdated

Return type

int

async peek(index)#

Peek at the rate-item at a specific index in latest-to-earliest order NOTE: The reason we cannot peek from the start of the queue(earliest-to-latest) is we can’t really tell how many outdated items are still in the queue

Return type

Optional[RateItem]

async put(item)#

Put an item (typically the current time) in the bucket return true if successful, otherwise false

property rates#
async waiting(item)#

Calculate time until bucket become availabe to consume an item again

Return type

int