Skip to main content

LockFileSemaphore

A production-grade file-based semaphore to control concurrent access to shared resources across multiple processes or machines.

Includes atomic lock creation, stale lock recovery, timeout handling, and context manager support.

Installation

pip install LockFileSemaphore

Example Usage

Traditional style:

from LockFileSemaphore import begin_semaphore_ops, end_semaphore_ops

lock_id = begin_semaphore_ops("/tmp/resource.lock") #put path to lock file here , may be arbitrary
try:
    # Critical section
    pass
finally:
    end_semaphore_ops("/tmp/resource.lock", lock_id)

Context Manager style:

from LockFileSemaphore import FileLock

with FileLock("/tmp/resource.lock"): #put path to lock file here, may be arbitrary
    # Critical section
    pass

Features

  • Atomic file lock creation (O_CREAT | O_EXCL)
  • Stale lock detection and automatic cleanup
  • Timeout and retry interval configuration
  • Context manager support
  • Cross-platform compatibility

Metadata

Release files for LockFileSemaphore 3.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LockFileSemaphore 3.0.2
File Size Uploaded
lockfilesemaphore-3.0.2.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for LockFileSemaphore 3.0.2
File Interpreter ABI Platform
lockfilesemaphore-3.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / lockfilesemaphore-3.0.2.tar.gz

Download URL lockfilesemaphore-3.0.2.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
81900a030129bc4ec1bf73859497c998c6ab08e15600219e18dc43bb91ba6fb6
BLAKE2b-256 checksum
How to use checksums
103740c0187fffaf1b3269b4c87ca88b9c52ab4dd7db4dd38ac78103432cf1bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release files / lockfilesemaphore-3.0.2-py3-none-any.whl

Download URL lockfilesemaphore-3.0.2-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
972f31e2aa18d44835f0f839f34649b3f769a30dd5a61064599b59572c410732
BLAKE2b-256 checksum
How to use checksums
15cc856d2ca2bb84e533483caab003a226aa8fad9158a8b792f4f9636e4ec0a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

3.0.2 This release

2 release files

3.0.1

2 release files

3.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page