Metadata-Version: 2.4
Name: combo_lock
Version: 0.3.0
Summary: A combined process and thread lock
Author-email: Åke Forslund <ake.forslund@gmail.com>, JarbasAI <jarbasai@mailfence.com>
License: Apache License v2.0
Project-URL: Repository, https://github.com/forslund/combo-lock
Project-URL: Homepage, https://github.com/forslund/combo-lock
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: filelock~=3.0
Requires-Dist: memory-tempfile
Dynamic: license-file

# Combo Lock

The combo-lock is a combination of a process lock and a thread lock. Usable in cases both multiple threads and multiple processes are sharing the same resource such as a file in the file system.

The module utilizes the FileLock from [filelock](https://pypi.org/project/filelock/) and the standard *Lock* from threading.

The FileLock uses a filesystem lock so the initialization of the class requires a path for the lock file.

## Example

```python
from combo_lock import ComboLock

lock = ComboLock('/tmp/my.lock')

with lock:
    write_my_shared_resource()


```

A `NamedLock` will save the lock file to shared memory using [memory-tempfile](https://github.com/mbello/memory-tempfile)

```python
from combo_lock import NamedLock

lock = NamedLock('some_name')

with lock:
    write_my_shared_resource()
```

### History

The combo-lock was originally created for [Mycroft-core](https://github.com/mycroftai/mycroft-core) but as it's been useful in other projects a separate release seemed appropriate.
