Database Models (lockmgr.models)

Functions

default_lock_expiry()

Classes

Lock(name, locked_by, lock_process, …)

class lockmgr.models.Lock(name, locked_by, lock_process, locked_until, created_at, updated_at)[source]
exception DoesNotExist
exception MultipleObjectsReturned
property expired

Property - returns True if the Lock is past expiry ( locked_until ), otherwise False

property expires_in

The amount of time until this lock expires, as a timedelta - or None if it doesn’t expire

property expires_seconds

The amount of seconds until this lock expires as integer seconds - or None if it doesn’t expire

locked_by

Name of the node / app which created this lock

locked_until

Locks have an expiration time, to help avoid the issue of stuck locks, either due to forgetting to add cleanup code, or simply due to the app/server crashing before it can release the lock.

After a lock has expired, it’s assumed that the lock is stale and needs to be removed, and the affected resources are safe to use.

name

Unique name of the lock, referring to what specific resource(s) is locked