certbot.lock
¶
Implements file locks for locking files and directories in UNIX.
-
certbot.lock.
lock_dir
(dir_path)[source]¶ Place a lock file on the directory at dir_path.
The lock file is placed in the root of dir_path with the name .certbot.lock.
Parameters: dir_path (str) – path to directory Returns: the locked LockFile object Return type: LockFile Raises: errors.LockError – if unable to acquire the lock
-
class
certbot.lock.
LockFile
(path)[source]¶ Bases:
object
A UNIX lock file.
This lock file is released when the locked file is closed or the process exits. It cannot be used to provide synchronization between threads. It is based on the lock_file package by Martin Horcicka.
-
acquire
()[source]¶ Acquire the lock file.
Raises: - errors.LockError – if lock is already held
- OSError – if unable to open or stat the lock file
-
_try_lock
(fd)[source]¶ Try to acquire the lock file without blocking.
Parameters: fd (int) – file descriptor of the opened file to lock
-
_lock_success
(fd)[source]¶ Did we successfully grab the lock?
Because this class deletes the locked file when the lock is released, it is possible another process removed and recreated the file between us opening the file and acquiring the lock.
Parameters: fd (int) – file descriptor of the opened file to lock Returns: True if the lock was successfully acquired Return type: bool
-