eon.locking¶
Module Contents¶
Classes¶
API¶
- class eon.locking.LockFile(lock_path)[source]¶
Initialization
- acquirelock()[source]¶
Create the lock, or take it over when the holder is gone.
The create is
O_CREAT|O_EXCL|O_WRONLY. The pid is written and fsynced, and on platforms with fcntl the descriptor is held under an exclusive flock for the life of this process. If the file already exists, a dead pid or a truncated file is removed and the create is tried once more. A live pid whose flock is not held is the same as a dead holder: the pid was reused.
- removelock()[source]¶
Unlink the lock when this process still owns it.
A forked child inherits this method, the stored pid, and the atexit hook. Exit in the child must not delete the parent’s file. A missing file, or a file another driver has replaced, is left alone. A LockFile that never acquired the lock does not delete whatever happens to sit at the path.