- class pyrate_limiter.sqlite_bucket.FileLockSQLiteBucket(**kwargs)#
Bucket backed by a SQLite database and file lock. Suitable for usage from multiple processes with no shared state. Requires installing [py-filelock](https://py-filelock.readthedocs.io).
The file lock is reentrant and shared across buckets, allowing a process to access multiple buckets at once.
- class pyrate_limiter.sqlite_bucket.SQLiteBucket(maxsize=0, identity=None, path=PosixPath('/tmp/pyrate_limiter.sqlite'), **kwargs)#
Bucket backed by a SQLite database. Will be stored in the system temp directory by default.
Notes on concurrency:
For other usage with multiple processes, see
Transactions are locked at the bucket level, but not at the connection or database level.
The default isolation level is used (autocommit).
Multitple buckets may be used in parallel, but a given bucket will only be used by one thread/process at a time.
Close the database connection
- property connection#
Create a database connection and initialize the table, if it hasn’t already been done. This is safe to leave open, but may be manually closed with
close(), if needed.
- Return type
Get items and remove them from the bucket in the FIFO fashion. Return the number of items that have been removed.
- Return type
Acquire a lock prior to beginning a new transaction
Release lock following a transaction