Metadata-Version: 2.4
Name: LockFileSemaphore
Version: 3.0.0
Summary: Robust file-based semaphore with stale lock recovery and context manager support.
Author: Marcin Kowalczyk
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# 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

```bash
pip install semaphore_v3
```

## Example Usage

### Traditional style:

```python
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:

```python
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
