1PY-FILELOCK(1)                    py-filelock                   PY-FILELOCK(1)
2
3
4

NAME

6       py-filelock - py-filelock Documentation
7
8       A platform independent file lock that supports the with-statement.
9
10       class filelock.BaseFileLock(lock_file, timeout=- 1)
11              Bases: object
12
13              Implements the base class of a file lock.
14
15              acquire(timeout=None, poll_intervall=0.05)
16                     Acquires the file lock or fails with a Timeout error.
17
18                        # You can use this method in the context manager (recommended)
19                        with lock.acquire():
20                            pass
21
22                        # Or use an equivalent try-finally construct:
23                        lock.acquire()
24                        try:
25                            pass
26                        finally:
27                            lock.release()
28
29                     Parameters
30
31timeout  (float)  -- The maximum time waited for
32                              the file lock.  If timeout  <  0,  there  is  no
33                              timeout  and  this  method  will block until the
34                              lock could be acquired.  If timeout is None, the
35                              default timeout is used.
36
37poll_intervall  (float)  --  We  check  once  in
38                              poll_intervall seconds if  we  can  acquire  the
39                              file lock.
40
41                     Raises Timeout  --  if  the lock could not be acquired in
42                            timeout seconds.
43
44                     Changed in version 2.0.0: This method returns now a proxy
45                     object  instead of self, so that it can be used in a with
46                     statement without side effects.
47
48
49              property is_locked
50                     True, if the object holds the file lock.
51
52                     Changed in version 2.0.0: This was  previously  a  method
53                     and is now a property.
54
55
56              property lock_file
57                     The path to the lock file.
58
59              release(force=False)
60                     Releases the file lock.
61
62                     Please note, that the lock is only completly released, if
63                     the lock counter is 0.
64
65                     Also note, that the lock file itself is not automatically
66                     deleted.
67
68                     Parameters
69                            force  (bool)  -- If true, the lock counter is ig‐
70                            nored and the lock is released in every case.
71
72              property timeout
73                     You can set a default timeout for the filelock.  It  will
74                     be  used  as  fallback value in the acquire method, if no
75                     timeout value (None) is given.
76
77                     If you want to disable the timeout, set it to a  negative
78                     value.
79
80                     A  timeout  of 0 means, that there is exactly one attempt
81                     to acquire the file lock.
82
83                     New in version 2.0.0.
84
85
86       filelock.FileLock
87              Alias for the lock, which should be used for the  current  plat‐
88              form.  On Windows, this is an alias for WindowsFileLock, on Unix
89              for UnixFileLock and otherwise for SoftFileLock.
90
91              alias of filelock.UnixFileLock
92
93       class filelock.SoftFileLock(lock_file, timeout=- 1)
94              Bases: filelock.BaseFileLock
95
96              Simply watches the existence of the lock file.
97
98       exception filelock.Timeout(lock_file)
99              Bases: TimeoutError
100
101              Raised when the lock could not be acquired in timeout seconds.
102
103              lock_file
104                     The path of the file lock.
105
106       class filelock.UnixFileLock(lock_file, timeout=- 1)
107              Bases: filelock.BaseFileLock
108
109              Uses the fcntl.flock() to hard lock the lock file on  unix  sys‐
110              tems.
111
112       class filelock.WindowsFileLock(lock_file, timeout=- 1)
113              Bases: filelock.BaseFileLock
114
115              Uses the msvcrt.locking() function to hard lock the lock file on
116              windows systems.
117

LICENSE

119       py-filelock is public domain:
120
121          This is free and unencumbered software released into the public domain.
122
123          Anyone is free to copy, modify, publish, use, compile, sell, or
124          distribute this software, either in source code form or as a compiled
125          binary, for any purpose, commercial or non-commercial, and by any
126          means.
127
128          In jurisdictions that recognize copyright laws, the author or authors
129          of this software dedicate any and all copyright interest in the
130          software to the public domain. We make this dedication for the benefit
131          of the public at large and to the detriment of our heirs and
132          successors. We intend this dedication to be an overt act of
133          relinquishment in perpetuity of all present and future rights to this
134          software under copyright law.
135
136          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
137          EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
138          MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
139          IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
140          OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
141          ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
142          OTHER DEALINGS IN THE SOFTWARE.
143
144          For more information, please refer to <http://unlicense.org>
145

GITHUB

147       This module is hosted on GitHub. If you have any questions  or  sugges‐
148       tions, don't hesitate to open a new issue :).
149

AUTHOR

151       Benedikt Schmitt
152
154       2021, Benedikt Schmitt
155
156
157
158
1593.0.12                           Jul 27, 2021                   PY-FILELOCK(1)
Impressum