AlkantarClanX12

Your IP : 3.148.108.201


Current Path : /opt/alt/python37/lib/python3.7/site-packages/virtualenv/util/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/virtualenv/util/__pycache__/lock.cpython-37.pyc

B

���a��@s�dZddlmZmZddlZddlZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZmZddlmZdd	lmZGd
d�de�ZiZe�Zee�Gdd
�d
e��ZGdd�de�ZGdd�de�ZdZdS)z7holds locking functionality that works across processes�)�absolute_import�unicode_literalsN)�ABCMeta�abstractmethod)�contextmanager)�Lock�RLock)�FileLock�Timeout)�
add_metaclass)�Pathcs8eZdZ�fdd�Zd
�fdd�	Zd�fdd	�	Z�ZS)�_CountedFileLockcs^tj�|�}tj�|�s<yt�|�Wntk
r:YnXtt|��|�d|_	t
�|_dS)Nr)�os�path�dirname�isdir�makedirs�OSError�superr
�__init__�countr�thread_safe)�self�	lock_file�parent)�	__class__��E/opt/alt/python37/lib/python3.7/site-packages/virtualenv/util/lock.pyrsz_CountedFileLock.__init__N皙�����?c	s@|j�0|jdkr$tt|��||�|jd7_WdQRXdS)Nr�)rrrr
�acquire)r�timeoutZ
poll_interval)rrrr s
z_CountedFileLock.acquireFc	sD|j�4|jdkr$tt|�j|d�t|jdd�|_WdQRXdS)Nr)�forcer)rrrr
�release�max)rr")rrrr#"s
z_CountedFileLock.release)Nr)F)�__name__�
__module__�__qualname__rr r#�
__classcell__rr)rrr
sr
c@sfeZdZdd�Zdd�Zdd�Zdd�Zed	d
��Zedd��Z	ee
ddd���Zee
dd���ZdS)�PathLockBasecCs"t|�}|��r|��n||_dS)N)r�exists�resolver)r�folderrrrrr/szPathLockBase.__init__cCsd�|jj|j�S)Nz{}({}))�formatrr%r)rrrr�__repr__3szPathLockBase.__repr__cCst|�|j|�S)N)�typer)r�otherrrr�__div__6szPathLockBase.__div__cCs
|�|�S)N)r1)rr0rrr�__truediv__9szPathLockBase.__truediv__cCst�dS)N)�NotImplementedError)rrrr�	__enter__<szPathLockBase.__enter__cCst�dS)N)r3)r�exc_type�exc_val�exc_tbrrr�__exit__@szPathLockBase.__exit__FcCst�dS)N)r3)r�name�no_blockrrr�lock_for_keyDszPathLockBase.lock_for_keycCst�dS)N)r3)r9rrr�non_reentrant_lock_for_keyIsz'PathLockBase.non_reentrant_lock_for_keyN)F)
r%r&r'rr.r1r2rr4r8rr;r<rrrrr)-sr)cszeZdZ�fdd�Zddd�Zedd��Zdd	�Zd
d�Zdd
�Z	ddd�Z
edd��Zeddd��Z
edd��Z�ZS)�ReentrantFileLockcstt|��|�d|_dS)N)rr=r�_lock)rr,)rrrrPszReentrantFileLock.__init__�c	Cs@t|jd�|��}t�|tkr.t|�t|<t|SQRXdS)Nz{}.lock)�strrr-�_store_lock�_lock_storer
)rr9rrrr�_create_lockTs
zReentrantFileLock._create_lockc
CsF|dk	rBt�0|j�|jdkr.t�|jd�WdQRXWdQRXdS)Nr)rArrrB�popr)�lockrrr�	_del_lock[s

zReentrantFileLock._del_lockcCs|�|j�dS)N)rFr>)rrrr�__del__cszReentrantFileLock.__del__cCs|��|_|�|j�dS)N)rCr>�
_lock_file)rrrrr4fs
zReentrantFileLock.__enter__cCs"|�|j�|�|j�d|_dS)N)�_releaser>rF)rr5r6r7rrrr8jszReentrantFileLock.__exit__FcCsvyt�t|j��Wntk
r(YnXy|�d�Wn8tk
rp|rN�t�d|j	�|�
�|��YnXdS)Ng-C��6?z/lock file %s present, will block until released)rrr@rrr r
�logging�debugrr#)rrEr:rrrrHoszReentrantFileLock._lock_filecCs|��dS)N)r#)rErrrrI�szReentrantFileLock._releasec	csH|�|�}z(z|�||�dVWd|�|�XWd|�|�d}XdS)N)rCrHrIrF)rr9r:rErrrr;�s


zReentrantFileLock.lock_for_keyc	cs.tt|jd�|����dVWdQRXdS)Nz{}.lock)r
r@rr-)rr9rrrr<�sz,ReentrantFileLock.non_reentrant_lock_for_key)r?)F)F)r%r&r'rrC�staticmethodrFrGr4r8rHrIrr;r<r(rr)rrr=Os

r=c@s6eZdZdd�Zdd�Zeddd��Zedd	��Zd
S)�NoOpFileLockcCst�dS)N)r3)rrrrr4�szNoOpFileLock.__enter__cCst�dS)N)r3)rr5r6r7rrrr8�szNoOpFileLock.__exit__Fccs
dVdS)Nr)rr9r:rrrr;�szNoOpFileLock.lock_for_keyccs
dVdS)Nr)rr9rrrr<�sz'NoOpFileLock.non_reentrant_lock_for_keyN)F)r%r&r'r4r8rr;r<rrrrrM�s
rM)rMr=r
)�__doc__�
__future__rrrJr�abcrr�
contextlibr�	threadingrrZfilelockr	r
ZsixrZvirtualenv.util.pathrr
rBrA�objectr)r=rM�__all__rrrr�<module>s"!H