AlkantarClanX12

Your IP : 18.226.200.93


Current Path : /proc/self/root/lib/python2.7/site-packages/pip/_vendor/lockfile/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyo

�
��abc
@@sdZddlmZddlZddlZddlZddlZddlZeed�spej	e_
neejd�s�ejjej_
ndddd	d
ddd
dddddg
Zdefd��YZdefd��YZdefd��YZd	efd��YZd
efd��YZdefd��YZdefd��YZd
efd��YZdefd��YZdefd��YZd�Zd�Zd �Zd!�Zdd"�Z eed#�r�d$d%l!m"Z#e#j$Z%nd$d&l!m&Z'e'j(Z%e%Z)dS('s
lockfile.py - Platform-independent advisory file locks.

Requires Python 2.5 unless you apply 2.4.diff
Locking is done on a per-thread basis instead of a per-process basis.

Usage:

>>> lock = LockFile('somefile')
>>> try:
...     lock.acquire()
... except AlreadyLocked:
...     print 'somefile', 'is locked already.'
... except LockFailed:
...     print 'somefile', 'can\'t be locked.'
... else:
...     print 'got lock'
got lock
>>> print lock.is_locked()
True
>>> lock.release()

>>> lock = LockFile('somefile')
>>> print lock.is_locked()
False
>>> with lock:
...    print lock.is_locked()
True
>>> print lock.is_locked()
False

>>> lock = LockFile('somefile')
>>> # It is okay to lock twice from the same thread...
>>> with lock:
...     lock.acquire()
...
>>> # Though no counter is kept, so you can't unlock multiple times...
>>> print lock.is_locked()
False

Exceptions:

    Error - base class for other exceptions
        LockError - base class for all locking exceptions
            AlreadyLocked - Another thread or process already holds the lock
            LockFailed - Lock failed for some other reason
        UnlockError - base class for all unlocking exceptions
            AlreadyUnlocked - File was not locked.
            NotMyLock - File was locked but not by the current thread/process
i(tabsolute_importNtcurrent_threadtget_nametErrort	LockErrortLockTimeoutt
AlreadyLockedt
LockFailedtUnlockErrort	NotLockedt	NotMyLocktLinkFileLockt
MkdirFileLocktSQLiteFileLocktLockBasetlockedcB@seZdZRS(sw
    Base class for other exceptions.

    >>> try:
    ...   raise Error
    ... except Exception:
    ...   pass
    (t__name__t
__module__t__doc__(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyRJscB@seZdZRS(s�
    Base class for error arising from attempts to acquire the lock.

    >>> try:
    ...   raise LockError
    ... except Error:
    ...   pass
    (RRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyRVscB@seZdZRS(s�Raised when lock creation fails within a user-defined period of time.

    >>> try:
    ...   raise LockTimeout
    ... except LockError:
    ...   pass
    (RRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyRbscB@seZdZRS(s�Some other thread/process is locking the file.

    >>> try:
    ...   raise AlreadyLocked
    ... except LockError:
    ...   pass
    (RRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyRmscB@seZdZRS(s�Lock file creation failed for some other reason.

    >>> try:
    ...   raise LockFailed
    ... except LockError:
    ...   pass
    (RRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyRxscB@seZdZRS(s�
    Base class for errors arising from attempts to release the lock.

    >>> try:
    ...   raise UnlockError
    ... except Error:
    ...   pass
    (RRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR�scB@seZdZRS(s�Raised when an attempt is made to unlock an unlocked file.

    >>> try:
    ...   raise NotLocked
    ... except UnlockError:
    ...   pass
    (RRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR	�scB@seZdZRS(s�Raised when an attempt is made to unlock a file someone else locked.

    >>> try:
    ...   raise NotMyLock
    ... except UnlockError:
    ...   pass
    (RRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR
�st_SharedBasecB@sAeZd�Zdd�Zd�Zd�Zd�Zd�ZRS(cC@s
||_dS(N(tpath(tselfR((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt__init__�scC@std��dS(s�
        Acquire the lock.

        * If timeout is omitted (or None), wait forever trying to lock the
          file.

        * If timeout > 0, try to acquire the lock for that many seconds.  If
          the lock period expires and the file is still locked, raise
          LockTimeout.

        * If timeout <= 0, raise AlreadyLocked immediately if the file is
          already locked.
        simplement in subclassN(tNotImplemented(Rttimeout((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pytacquire�scC@std��dS(sX
        Release the lock.

        If the file is not locked, raise NotLocked.
        simplement in subclassN(R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pytrelease�scC@s|j�|S(s*
        Context manager support.
        (R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt	__enter__�s
cG@s|j�dS(s*
        Context manager support.
        N(R(Rt_exc((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt__exit__�scC@sd|jj|jfS(Ns<%s: %r>(t	__class__RR(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt__repr__�sN(	RRRtNoneRRRRR(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR�s				cB@sAeZdZedd�Zd�Zd�Zd�Zd�Z	RS(s.Base class for platform-specific lock classes.cC@s�tt|�j|�tjj|�d|_tj�|_	tj
�|_|r�tj
�}t|dt|��}d|d@|_n	d|_tjj|j�}tjj|d|j	|j|jt|j�f�|_||_dS(si
        >>> lock = LockBase('somefile')
        >>> lock = LockBase('somefile', threaded=False)
        s.locktidents-%xI����ts	%s%s.%s%sN(tsuperRRtosRtabspatht	lock_filetsockettgethostnamethostnametgetpidtpidt	threadingRtgetattrthashttnametdirnametjointunique_nameR(RRtthreadedRttR!R0((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR�s 			cC@std��dS(s9
        Tell whether or not the file is locked.
        simplement in subclassN(R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt	is_locked�scC@std��dS(sA
        Return True if this object is locking the file.
        simplement in subclassN(R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyti_am_locking�scC@std��dS(sN
        Remove a lock.  Useful if a locking thread failed to unlock.
        simplement in subclassN(R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt
break_lockscC@sd|jj|j|jfS(Ns<%s: %r -- %r>(RRR2R(R((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyRsN(
RRRtTrueR RR5R6R7R(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR�s!			cO@smtjd|tdd�t|dt�s:|d}nt|�dkr`|r`t|d<n|||�S(Ns1Import from %s module instead of lockfile packaget
stackleveliiiR3(twarningstwarntDeprecationWarningt
isinstancetstrtlenR8(tclstmodtargstkwds((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt
_fl_helpers



cO@s&ddlm}t|jd||�S(s�Factory function provided for backwards compatibility.

    Do not use in new code.  Instead, import LinkLockFile from the
    lockfile.linklockfile module.
    i(tlinklockfileslockfile.linklockfile(R"RERDtLinkLockFile(RBRCRE((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyRscO@s&ddlm}t|jd||�S(s�Factory function provided for backwards compatibility.

    Do not use in new code.  Instead, import MkdirLockFile from the
    lockfile.mkdirlockfile module.
    i(t
mkdirlockfileslockfile.mkdirlockfile(R"RGRDt
MkdirLockFile(RBRCRG((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR%scO@s&ddlm}t|jd||�S(s�Factory function provided for backwards compatibility.

    Do not use in new code.  Instead, import SQLiteLockFile from the
    lockfile.mkdirlockfile module.
    i(tsqlitelockfileslockfile.sqlitelockfile(R"RIRDtSQLiteLockFile(RBRCRI((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR
0sc@s��fd�}|S(sDecorator which enables locks for decorated function.

    Arguments:
     - path: path for lockfile.
     - timeout (optional): Timeout for acquiring lock.

     Usage:
         @locked('/var/run/myname', timeout=0)
         def myname(...):
             ...
    c@s(tj�����fd��}|S(Nc@s?t�d��}|j�z�||�SWd|j�XdS(NR(tFileLockRR(RBtkwargstlock(tfuncRR(sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pytwrapperHs

(t	functoolstwraps(RNRO(RR(RNsA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pytdecorGs$((RRRR((RRsA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyR;s
tlinki(RE(RG(*Rt
__future__RRPR$R'R,R:thasattrt
currentThreadRtThreadtgetNameRt__all__t	ExceptionRRRRRRR	R
tobjectRRRDRRR
R RR"REt_llfRFtLockFileRGt_mlfRHRK(((sA/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/__init__.pyt<module>4sF	-: