Simple Lockfile System.
Project description
[![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/ansicolortags/)
[![Build Status](https://travis-ci.org/0h-n0/simple-lock.svg?branch=master)](https://travis-ci.org/0h-n0/simple-lock)
[![codecov](https://codecov.io/gh/0h-n0/view-lockfile/branch/master/graph/badge.svg)](https://codecov.io/gh/0h-n0/view-lockfile)
[![Maintainability](https://api.codeclimate.com/v1/badges/9a8b4b39d3673ccb6db6/maintainability)](https://codeclimate.com/github/0h-n0/simple-lock/maintainability)
# simple-lock
> Note
Simple-lockfile uses a file as a lock system.
## Coencept
## How to use
The following example is based on Django project. With this module, you can lock a view method in your app.
```settings.py
from simple_lock import SimpleLock
# ~~~
File.set_root_path('/home/hoge/')
# A lockfile is created in the root_path directory without setting path as arguments.
```
```app/view.py
from response_lockfile import lock_lockfile
# ~~~
@lock_view(name='lockfile1.lock')
def view():
#some_logic
return HttpResponse()
```
This decoreator creates lockfile1.lock and releases.
```app2/view.py
from response_lockfile import watch_lockfile
# ~~~
@watch_lockfile(name='lockfile1.lock')
def view():
return HttpResponse()
```
If lockfile1.lock exists when execute app2/view:view, this decoreator returns a http response.
[![Build Status](https://travis-ci.org/0h-n0/simple-lock.svg?branch=master)](https://travis-ci.org/0h-n0/simple-lock)
[![codecov](https://codecov.io/gh/0h-n0/view-lockfile/branch/master/graph/badge.svg)](https://codecov.io/gh/0h-n0/view-lockfile)
[![Maintainability](https://api.codeclimate.com/v1/badges/9a8b4b39d3673ccb6db6/maintainability)](https://codeclimate.com/github/0h-n0/simple-lock/maintainability)
# simple-lock
> Note
Simple-lockfile uses a file as a lock system.
## Coencept
## How to use
The following example is based on Django project. With this module, you can lock a view method in your app.
```settings.py
from simple_lock import SimpleLock
# ~~~
File.set_root_path('/home/hoge/')
# A lockfile is created in the root_path directory without setting path as arguments.
```
```app/view.py
from response_lockfile import lock_lockfile
# ~~~
@lock_view(name='lockfile1.lock')
def view():
#some_logic
return HttpResponse()
```
This decoreator creates lockfile1.lock and releases.
```app2/view.py
from response_lockfile import watch_lockfile
# ~~~
@watch_lockfile(name='lockfile1.lock')
def view():
return HttpResponse()
```
If lockfile1.lock exists when execute app2/view:view, this decoreator returns a http response.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
simple_lock-1.0.0.tar.gz
(3.8 kB
view hashes)
Built Distributions
simple_lock-1.0.0-py3.6.egg
(7.7 kB
view hashes)
Close
Hashes for simple_lock-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b16bd28dc8b333ee8ae80e233abfa91e7629e55ae5e7fd1da793c235b601f236 |
|
MD5 | 9877459a8745bd7ac51523aee391be41 |
|
BLAKE2b-256 | ab194915d6878299a6d7f1caf7391ac2e9a11bb687b19addc3260831eefd4ae4 |