AlkantarClanX12

Your IP : 18.217.4.250


Current Path : /lib/python2.7/site-packages/pip/_vendor/lockfile/
Upload File :
Current File : //lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyc

�
��abc@@s�dZddlmZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZdefd��YZ
d�Zd	�Zd
�ZdS(s8 Lockfile behaviour implemented via Unix PID files.
    i(tabsolute_importNi(tLockBaset
AlreadyLockedt
LockFailedt	NotLockedt	NotMyLocktLockTimeouttPIDLockFilecB@sVeZdZedd�Zd�Zd�Zd�Zdd�Z	d�Z
d�ZRS(	sA Lockfile implemented as a Unix PID file.

    The lock file is a normal file named by the attribute `path`.
    A lock's PID file contains a single line of text, containing
    the process ID (PID) of the process that acquired the lock.

    >>> lock = PIDLockFile('somefile')
    >>> lock = PIDLockFile('somefile')
    cC@s&tj||t|�|j|_dS(N(Rt__init__tFalsetpathtunique_name(tselfR
tthreadedttimeout((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyR$scC@s
t|j�S(s- Get the PID from the lock file.
            (tread_pid_from_pidfileR
(R((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pytread_pid*scC@stjj|j�S(sv Test if the lock is currently held.

            The lock is held if the PID file for this lock exists.

            (tosR
texists(R((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyt	is_locked/scC@s"|j�o!tj�|j�kS(s� Test if the lock is held by the current process.

        Returns ``True`` if the current process ID matches the
        number stored in the PID file.
        (RRtgetpidR(R((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyti_am_locking7scC@s)|dk	r|n|j}tj�}|dk	rL|dkrL||7}nx�tr$yt|j�Wn�tk
r}|jtjkrtj�|kr�|dk	r�|dkr�t	d|j��q�t
d|j��ntj|dk	r�|dp�d�q!td|j��qOXdSqOWdS(s� Acquire the lock.

        Creates the PID file for this lock, or raises an error if
        the lock could not be acquired.
        is&Timeout waiting to acquire lock for %ss%s is already lockedi
g�������?sfailed to create %sN(
tNoneRttimetTruetwrite_pid_to_pidfileR
tOSErrorterrnotEEXISTRRtsleepR(RRtend_timetexc((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pytacquire?s$
	&cC@sU|j�s"td|j��n|j�sDtd|j��nt|j�dS(s� Release the lock.

            Removes the PID file to release the lock, or raises an
            error if the current process does not hold the lock.

            s%s is not lockeds%s is locked, but not by meN(RRR
RRtremove_existing_pidfile(R((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pytrelease_s
cC@st|j�dS(s� Break an existing lock.

            Removes the PID file if it already exists, otherwise does
            nothing.

            N(R!R
(R((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyt
break_locklsN(t__name__t
__module__t__doc__R	RRRRRR R"R#(((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyRs				 	
cC@sqd}yt|d�}Wntk
r,nAX|j�j�}yt|�}Wntk
rbnX|j�|S(s� Read the PID recorded in the named PID file.

        Read and return the numeric PID recorded as text in the named
        PID file. If the PID file cannot be read, or if the content is
        not a valid PID, return ``None``.

        trN(RtopentIOErrortreadlinetstriptintt
ValueErrortclose(tpidfile_pathtpidtpidfiletline((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyRvs


cC@sotjtjBtjB}d}tj|||�}tj|d�}tj�}|jd|�|j�dS(s� Write the PID in the named PID file.

        Get the numeric process ID (“PID”) of the current process
        and write it to the named file as a line of text.

        i�tws%s
N(	RtO_CREATtO_EXCLtO_WRONLYR(tfdopenRtwriteR.(R/t
open_flagst	open_modet
pidfile_fdR1R0((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyR�s	cC@sCytj|�Wn+tk
r>}|jtjkr8q?�nXdS(s� Remove the named PID file if it exists.

        Removing a PID file that doesn't already exist puts us in the
        desired state, so we ignore the condition if the file does not
        exist.

        N(RtremoveRRtENOENT(R/R((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyR!�s(R&t
__future__RRRRtRRRRRRRRRR!(((sD/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/pidlockfile.pyt<module>
s.]	"