versioned_collection.collection.tracking_collections.lock module¶
- class versioned_collection.collection.tracking_collections.lock.LockCollection(*args: Any, **kwargs: Any)[source]¶
Bases:
CollectionCollection holding the locking information.
This collection is necessary when multiple users are concurrently interacting with a VersionedCollection.
The documents in this collection have the following format:
{ _id: ObjectId(...) collection_name: 'name of the tracked collection' locked: True/ False }
This collection is shared per database, holding information about each tracked collection in the database. By using atomic updates, each VersionedCollection can implement a simple locking mechanism.
- class SCHEMA(collection_name: str, locked: bool)[source]¶
Bases:
object- collection_name: str¶
- locked: bool¶
- lock_acquire(collection: str) bool[source]¶
Acquire the lock for the given collection.
- Parameters:
collection – The name of the collection to lock.
- Returns:
Whether the process waited for the lock.
- lock_release(collection: str) bool[source]¶
Release the lock for the given collection.
- Parameters:
collection – The name of the collection to unlock.
- Returns:
Whether the collection was locked.