Module locked_file
source code
Locked file interface that should work on Unix and Windows pythons.
This module first tries to use fcntl locking to ensure serialized access
to a file, then falls back on a lock file if that is unavialable.
Usage:
f = LockedFile('filename', 'r+b', 'rb')
f.open_and_lock()
if f.is_locked():
print 'Acquired filename with r+b mode'
f.file_handle().write('locked data')
else:
print 'Aquired filename with rb mode'
f.unlock_and_close()
Author:
cache@google.com (David T McWherter)
|
AlreadyLockedException
Trying to lock a file that has already been locked by the LockedFile.
|
|
_Opener
Base class for different locking primitives.
|
|
_PosixOpener
Lock files using Posix advisory lock files.
|
|
_FcntlOpener
Open, lock, and unlock a file using fcntl.lockf.
|
|
LockedFile
Represent a file that has exclusive access.
|
|
logger = logging.getLogger(__name__)
|
|
_Win32Opener = None
|
|
__package__ = ' oauth2client '
|