Edit File: linklockfile.cpython-36.pyc
3 )�]b\ ������������������@���sP���d�dl�mZ�d�dlZd�dlZddlmZmZmZmZm Z m Z �G�dd��de�ZdS�)�����)�absolute_importN����)�LockBase� LockFailed� NotLocked� NotMyLock�LockTimeout� AlreadyLockedc���������������@���s:���e�Zd�ZdZd dd�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) Nc�������������C���s"��yt�|�jd�j���W�n"�tk r6���td|�j���Y�nX�|d�k rD|n|�j}tj��}|d�k rj|dkrj||7�}x�ytj|�j|�j ��W�n��t k �r���tj|�j�j}|dkr�d�S�|d�k r�tj��|kr�tj |�j��|dkr�td|�j���ntd|�j���tj|d�k �r |d��pd��Y�qlX�d�S�qlW�d�S�) 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 ���Zsleep)�selfr���Zend_timeZnlinks��r����"/usr/lib/python3.6/linklockfile.py�acquire���s0���� $zLinkLockFile.acquirec�������������C���sP���|�j���std|�j���ntjj|�j�s4td|�j���tj|�j��tj|�j��d�S�)Nz%s is not lockedz%s is locked, but not by me) � is_lockedr���r���r����existsr���r���r���r���)r���r���r���r����release7���s����zLinkLockFile.releasec�������������C���s���t�jj|�j�S�)N)r���r���r!���r���)r���r���r���r���r ���?���s����zLinkLockFile.is_lockedc�������������C���s(���|�j���o&tjj|�j�o&tj|�j�jdkS�)Nr���)r ���r���r���r!���r���r���r���)r���r���r���r����i_am_lockingB���s����zLinkLockFile.i_am_lockingc�������������C���s���t�jj|�j�rt�j|�j��d�S�)N)r���r���r!���r���r���)r���r���r���r���� break_lockG���s����zLinkLockFile.break_lock)N) �__name__� __module__�__qualname__�__doc__r���r"���r ���r#���r$���r���r���r���r���r ��� ���s��� &r ���)Z __future__r���r���r�����r���r���r���r���r���r ���r ���r���r���r���r����<module>���s���