-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
51 lines (34 loc) · 1.36 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
quicklock
=========
A simple Python resource lock to ensure only one process at a time is
operating with a particular resource.
Singleton Usage
---------------
Singleton creates a file containing process information to ensure that
the process that created the lock is still alive. The default location
is in the ``.lock`` directory in the current working directory. If this
directory does not exist, ``singleton`` will create it automatically.
Simple usage:
^^^^^^^^^^^^^
.. code:: python
from quicklock import singleton
singleton('my-process') # This will ensure that only one of these is running at once
# The lock is released when the process that created the lock
# exits (successfully or quits unexpectedly)
# Intensive processing here
Specifying the lock directory:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code:: python
from quicklock import singleton
singleton('my-process', dirname='/var/lock') # Now all lock files will be written to
# /var/lock instead
# Intensive processing here
Contributing
------------
Please feel free to create issues and submit pull requests. I want to
keep this library as a simple collection of useful locking-related
utilities.
License
-------
The license is MIT, see the attached ``LICENSE`` file for more
information.