Your IP : 216.73.216.196


Current Path : /opt/alt/python35/lib/python3.5/site-packages/lockfile/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/lockfile/__pycache__/linklockfile.cpython-35.pyc



��UV\
�@spddlmZddlZddlZddlmZmZmZmZm	Z	m
Z
Gdd�de�ZdS)�)�absolute_importN�)�LockBase�
LockFailed�	NotLocked�	NotMyLock�LockTimeout�
AlreadyLockedc@sUeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�ZdS)
�LinkLockFilez�Lock access to a file using atomic property of link(2).

    >>> lock = LinkLockFile('somefile')
    >>> lock = LinkLockFile('somefile', threaded=False)
    NcCstyt|jd�j�Wn%tk
rAtd|j��YnX|dk	rT|n|j}tj�}|dk	r�|dkr�||7}x�ytj|j|j	�Wn�t
k
rgtj|j�j}|dkr�dS|dk	r@tj�|kr@tj
|j�|dkr-td|j��ntd|j��tj|dk	r\|dp_d�Yq�XdSq�WdS)	N�wbzfailed to create %sr�z&Timeout waiting to acquire lock for %sz%s is already locked�
g�������?)�open�unique_name�close�IOErrorr�timeout�time�os�link�	lock_file�OSError�stat�st_nlink�unlinkr�pathr	�sleep)�selfrZend_timeZnlinks�r�F/opt/alt/python35/lib/python3.5/site-packages/lockfile/linklockfile.py�acquires0



(zLinkLockFile.acquirecCsn|j�s"td|j��n(tjj|j�sJtd|j��tj|j�tj|j�dS)Nz%s is not lockedz%s is locked, but not by me)	�	is_lockedrrr�existsrrrr)rrrr�release7szLinkLockFile.releasecCstjj|j�S)N)rrr"r)rrrrr!?szLinkLockFile.is_lockedcCs:|j�o9tjj|j�o9tj|j�jdkS)Nr)r!rrr"rrr)rrrr�i_am_lockingBszLinkLockFile.i_am_lockingcCs)tjj|j�r%tj|j�dS)N)rrr"rr)rrrr�
break_lockGszLinkLockFile.break_lock)	�__name__�
__module__�__qualname__�__doc__r r#r!r$r%rrrrr

s&r
)�
__future__rrr�rrrrrr	r
rrrr�<module>s.