Project Description

The zc.lockfile package provides a basic portable implementation of
interprocess locks using lock files. The purpose if not specifically
to lock files, but to simply provide locks with an implementation
based on file-locking primitives. Of course, these locks could be
used to mediate access to other files. For example, the ZODB file
storage implementation uses file locks to mediate access to
file-storage database files. The database files and lock file files
are separate files.

The ZODB lock_file module provides support for creating file system
locks. These are locks that are implemented with lock files and
OS-provided locking facilities. To create a lock, instantiate a
LockFile object with a file name:

In a container environment (e.g. Docker), the PID is typically always
identical even if multiple containers are running under the same operating
system instance.

Clearly, inspecting lock files doesn’t then help much in debugging. To identify
the container which created the lock file, we need information about the
container in the lock file. Since Docker uses the container identifier or name
as the hostname, this information can be stored in the lock file in addition to
or instead of the PID.

Use the content_template keyword argument to LockFile to specify a
custom lock file content format: