infrahouse_toolkit.lock package

Subpackages

Submodules

infrahouse_toolkit.lock.base module

InfraHouse Lock interface.

class infrahouse_toolkit.lock.base.BaseLock[source]

Bases: object

Base Lock interface.

Provides public properties and methods.

property exclusive

Whether the lock is exclusive as opposite of shared.

property name

Descriptive for humans lock name.

property shared

Whether the lock is shared as opposite of exclusive.

infrahouse_toolkit.lock.exceptions module

Lock module exceptions.

exception infrahouse_toolkit.lock.exceptions.LockAcquireError[source]

Bases: IHException

When failed to acquire a lock.

infrahouse_toolkit.lock.system module

A system-wide Lock class. Where the system is a server, computer, container, and/or file system.

class infrahouse_toolkit.lock.system.SystemLock(lockfile: str, blocking: bool = True)[source]

Bases: BaseLock

Acquire a system-wide lock.

Parameters:
  • lockfile (str) – Path to a file on the local filesystem.

  • blocking (bool) – Whether the caller should wait for the lock or exception should be raised. If blocking is True, the caller will wait.

Raises:

LockAcquireError – If we tried to acquire the lock in a non-blocking mode and the lock is taken by somebody else.

Module contents