Metadata-Version: 2.4
Name: flockfile
Version: 0.2.0
Summary: A simple lock file class based on file locking.
Author-email: Ryan Veach <rveach@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://gitlab.com/rveach/flockfile
Project-URL: Source, https://gitlab.com/rveach/flockfile
Project-URL: Tracker, https://gitlab.com/rveach/flockfile/issues
Keywords: Lock,Flock
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# flockfile

Just a simple python lock file class using file locks.

## Installation

```bash
pip install flockfile
```

## Usage

```python
from flockfile import FlockFile, FileNotLocked

# init the class using a file name
# optionally, the directory can be set to something other than /tmp
lock = FlockFile("myscriptname", lock_dir="/tmp")


# lock the file
lock.lock()
# if this is unsuccessful, exception FileNotLocked will be raised.

# the following class method can be used to check lock status
assert lock.check_lock()

# unlock and delete file
lock.unlock()
```

`FlockFile` can also be used as a context manager. The lock is acquired on entry
(raising `FileNotLocked` if it cannot be obtained) and released on exit:

```python
from flockfile import FlockFile

with FlockFile("myscriptname", lock_dir="/tmp"):
    # the lock is held here
    ...
# the lock is released and the file deleted here
```

## Questions or Issues?

Please report as a Gitlab issue: https://gitlab.com/rveach/flockfile/issues

## A note on the use of AI

This library was initally created by hand and uploaded to PyPI in 2019. A lot has changed, so I've used AI to add a context manager and modernize the toolset. All commits using AI have been tagged as such.
