b.l.LockHeldInfo(object) : class documentation

Part of bzrlib.lockdir View In Hierarchy

The information recorded about a held lock.

This information is recorded into the lock when it's taken, and it can be read back by any process with access to the lockdir. It can be used, for example, to tell the user who holds the lock, or to try to detect whether the lock holder is still alive.

Prior to bzr 2.4 a simple dict was used instead of an object.

Method __init__ Undocumented
Method __repr__ Return a debugging representation of this object.
Method __unicode__ Return a user-oriented description of this object.
Method to_readable_dict Turn the holder info into a dict of human-readable attributes.
Method get Return the contents of a field from the lock info, or None.
Class Method for_this_process Return a new LockHeldInfo for a lock taken by this process.
Method to_bytes Undocumented
Class Method from_info_file_bytes Construct from the contents of the held file.
Method __cmp__ Value comparison of lock holders.
Method is_locked_by_this_process True if this process seems to be the current lock holder.
Method is_lock_holder_known_dead True if the lock holder process is known to be dead.
def __init__(self, info_dict):
Undocumented
def __repr__(self):
Return a debugging representation of this object.
def __unicode__(self):
Return a user-oriented description of this object.
def to_readable_dict(self):
Turn the holder info into a dict of human-readable attributes.

For example, the start time is presented relative to the current time, rather than as seconds since the epoch.

Returns a list of [user, hostname, pid, time_ago] all as readable strings.

def get(self, field_name):
Return the contents of a field from the lock info, or None.
@classmethod
def for_this_process(cls, extra_holder_info):
Return a new LockHeldInfo for a lock taken by this process.
def to_bytes(self):
Undocumented
@classmethod
def from_info_file_bytes(cls, info_file_bytes):
Construct from the contents of the held file.
def __cmp__(self, other):
Value comparison of lock holders.
def is_locked_by_this_process(self):
True if this process seems to be the current lock holder.
def is_lock_holder_known_dead(self):
True if the lock holder process is known to be dead.

False if it's either known to be still alive, or if we just can't tell.

We can be fairly sure the lock holder is dead if it declared the same hostname and there is no process with the given pid alive. If people have multiple machines with the same hostname this may cause trouble.

This doesn't check whether the lock holder is in fact the same process calling this method. (In that case it will return true.)

API Documentation for Bazaar, generated by pydoctor at 2019-07-19 00:30:15.