Metadata-Version: 2.1
Name: RWFileLock
Version: 0.2.2
Summary: Readers / writers file lock helper class
Home-page: https://github.com/inab/RWFileLock
Author: José M. Fernández <https://orcid.org/0000-0002-4806-5140>
Author-email: jose.m.fernandez@bsc.es
License: LGPLv2
Project-URL: Source, https://github.com/inab/RWFileLock
Project-URL: Bug Tracker, https://github.com/inab/RWFileLock/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# Readers / writers file lock Python helper class

[![Test PyPI Deployment](https://github.com/inab/RWFileLock/actions/workflows/build_n_deploy.yml/badge.svg)](https://github.com/inab/RWFileLock/actions/workflows/build_n_deploy.yml)

This library was created in order to ease the synchronization of several processes
using shared resources, like a caching directory or a SQLite database. All of them
can use the resources, but only one should update them.

The library is being used in several INB projects.

## Example of a shared lock using context:

```python
import datetime
import os
import time

from RWFileLock import RWFileLock

lock = RWFileLock("/tmp/rwfilelock.lock")
with lock.shared_lock():
    print(
        f"[{datetime.datetime.now().isoformat()}] Got shlock {os.getpid()}"
    )
	
    time.sleep(7)
    print(
        f"[{datetime.datetime.now().isoformat()}] Releasing shlock {os.getpid()}"
    )

```
