Lock

class lockmgr.models.Lock(name, locked_by, lock_process, locked_until, created_at, updated_at)[source]
__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

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

Methods

Methods

get_next_by_created_at(*[, field, is_next])

get_next_by_updated_at(*[, field, is_next])

get_previous_by_created_at(*[, field, is_next])

get_previous_by_updated_at(*[, field, is_next])

Attributes

Attributes

created_at

A wrapper for a deferred-loading field.

expired

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

expires_in

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

expires_seconds

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

lock_process

A wrapper for a deferred-loading field.

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.

name

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

objects

updated_at

A wrapper for a deferred-loading field.