[](https://github.com/0h-n0/simple-lock)
[](https://badge.fury.io/py/simple-lock)
[](https://travis-ci.org/0h-n0/simple-lock)
[](https://codecov.io/gh/0h-n0/simple-lock)
[](https://codeclimate.com/github/0h-n0/simple-lock/maintainability)
[](https://bettercodehub.com/)
# simple-lock
simple-lock provides lock system as a decorator or with-statement in your code. It is easy to use them.
## Concept
You can easily implement lock system in your application with modifing a few line. There are mainly two decorator in `simple_lock`. First, `simple_lock.lock` locks function and create a lockfile. After that, other functions refer to the lockfile can't be executed normally. Second, without creating a new lockfile, `simple_lock.watch` watchs a lockfile provieded as one of arguments without creating a new lockfile.
## Instalation
```shell
$ pip install simple-lock
```
## How to use
### Lock your function with `simple_lock.lock` decorator.
When a funciton try to create a lockfile and the lockfile already exists. `simple_lock.lock` decorator returns `return_value` like the following codes.
```test.py
from simple_lock import lock
@lock(filename='simple.lock', path='~/locks',
return_value=10)
def sleep():
import time
time.sleep(10)
sleep() # -> 10
```
You can provide a function as 'return_value' argument and arguments of 'return_value'.
```test.py
from simple_lock import lock
def add(a, b):
return a + b
@lock(filename='simple.lock', path='~/locks',
return_value=add
a=1, b=1)
def sleep():
import time
time.sleep(10)
sleep() # -> 2
```
`simple_lock.watch` also provides functions similar to `simple_lock.lock`. The difference between `simple_lock.lock` and `simple_lock.watch` is just whether lockfile is created or not.
```test.py
from simple_lock import watch
@watch(filename='simple.lock', path='~/locks',
return_value=10)
def sleep():
import time
time.sleep(10)
sleep() # -> 10
```
```test.py
from simple_lock import watch
def add(a, b):
return a + b
@watch(filename='simple.lock', path='~/locks',
return_value=add,
a=1, b=1)
def sleep():
import time
time.sleep(10)
sleep() # -> 2
```
## References
* https://github.com/benediktschmitt/py-filelock
Metadata
Release files for simple-lock 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_lock-1.0.6.tar.gz | 4.5 kB | Without provenance | Details for simple_lock-1.0.6.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_lock-1.0.6-py3.6.egg | Legacy Egg format | - | - | Details for simple_lock-1.0.6-py3.6.egg |
| simple_lock-1.0.6-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for simple_lock-1.0.6-py2.py3-none-any.whl |
Total release size: 18.6 kB
Release files / simple_lock-1.0.6.tar.gz
| Download URL | simple_lock-1.0.6.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6619df3417aa7b4ae81c37f308a740d0d30ae9a13cc68dbf50e32907e5ba491
|
|
BLAKE2b-256 checksum How to use checksums |
7c65df0aab01d85c6d60ee84ca5078ddf0c6778e5045cfbdfc6f3036ad823d7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/38.4.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.4
|
Release files / simple_lock-1.0.6-py3.6.egg
| Download URL | simple_lock-1.0.6-py3.6.egg |
|---|---|
| Size | 8.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
ca2bd6de5d2aa77162254fb921ab7627b0f678711639afd702bca74b885b0977
|
|
BLAKE2b-256 checksum How to use checksums |
aea2e14192194f3693a285e3f0b648abcdb79356d8ad2f0cfdd8e8b859fecb4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3
|
Release files / simple_lock-1.0.6-py2.py3-none-any.whl
| Download URL | simple_lock-1.0.6-py2.py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6716ab7caae23f5509730aa5b4b426d44f931ae10fa538851ae277632a21342c
|
|
BLAKE2b-256 checksum How to use checksums |
01f1fff71baebaa22e9958d9f0532b0e55c10248e4481120da5d553bd401ec0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3
|
Security for simple-lock 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.