API Reference

Abstract Base Classes

Base classes for distributed synchronization primitives

class tutti.base.LockABC

Abstract base class for Lock primitive

Mostly compatible with threading.Lock.

abstract acquire(blocking: bool = True, timeout: Optional[float] = None) → bool

Acquire a lock.

Parameters
  • blocking (bool) – Whether or not to block waiting for the lock. If blocking is set to True, block for up to timeout seconds (or forever if timeout is None).

  • timeout (Optional[float]) – Number of seconds to wait for the lock if it is not immediately available. Defaults to None.

Returns

success – True if lock was acquired successfully, False otherwise.

Return type

bool

abstract locked() → bool

Return True if the lock is locked

Returns

locked – True if the lock is held by anyone, not just this process.

Return type

bool

abstract release() → None

Release a lock.

Returns

Return type

None

Raises

RuntimeError – if called on an unlocked Lock.

class tutti.base.SemaphoreABC

Abstract Base Class for Semaphore primitive

Mostly compatible with threading.Semaphore.