pyrate_limiter.buckets.mp_bucket module

multiprocessing In-memory Bucket using a multiprocessing.Manager.ListProxy and a multiprocessing.Lock.

class pyrate_limiter.buckets.mp_bucket.MultiprocessBucket(rates, items, mp_lock)

Bases: InMemoryBucket

classmethod init(rates)

Creates a single ListProxy so that this bucket can be shared across multiple processes.

items
leak(current_timestamp=None)

leaking bucket - removing items that are outdated

Return type:

int

limiter_lock()

An additional lock to be used by Limiter in-front of the thread lock. Intended for multiprocessing environments where a thread lock is insufficient.

mp_lock
put(item)

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

Return type:

bool

rates