File: //proc/thread-self/root/usr/lib/python3/dist-packages/landscape/lib/__pycache__/lock.cpython-38.pyc
U
���c� � @ s6 d dl Z d dlZd dlZG dd� de�Zddd�ZdS )� Nc @ s e Zd ZdZdS )� LockErrorz"Raised when unable to lock a file.N)�__name__�
__module__�__qualname__�__doc__� r r �4/usr/lib/python3/dist-packages/landscape/lib/lock.pyr s r c s� t �| t j�� t�� tjd�}|tjO }t�� tj|� t�� }zt�� tj tj
B � W q� tk
r� |t�� | k r�td��Y nX q�t�
d� q@� fdd�}|S )Nr zCouldn't obtain lockg�������?c s t �� t j� t�� � d S )N)�fcntl�flockZLOCK_UN�os�closer ��fdr r �unlock_path s zlock_path.<locals>.unlock_path)r �open�O_CREATr ZF_GETFDZ
FD_CLOEXECZF_SETFD�timer
ZLOCK_EXZLOCK_NB�IOErrorr �sleep)�pathZtimeout�flagsZstartedr r r
r � lock_path
s
r )r )r r r � Exceptionr r r r r r �<module> s