Portable file locking utilities.
Based partially on an example by Jonathan Feignberg in the Python Cookbook [1] (licensed under the Python Software License) and a ctypes port by Anatoly Techtonik for Roundup [2] (license [3]).
[1] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203 [2] https://sourceforge.net/p/roundup/code/ci/default/tree/roundup/backends/portalocker.py [3] https://sourceforge.net/p/roundup/code/ci/default/tree/COPYING.txt
Example Usage:
>>> from django.core.files import locks >>> with open('./file', 'wb') as f: ... locks.lock(f, locks.LOCK_EX) ... f.write('Django')
Constant | LOCK_EX |
Undocumented |
Constant | LOCK_NB |
Undocumented |
Constant | LOCK_SH |
Undocumented |
Constant | LPOVERLAPPED |
Undocumented |
Class | _OFFSET |
Undocumented |
Class | _OFFSET_UNION |
Undocumented |
Class | OVERLAPPED |
Undocumented |
Function | _fd |
Get a filedescriptor from something which could be a file or an fd. |
Function | lock |
Undocumented |
Function | unlock |
Undocumented |