Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/python/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/python/lockfile.pyc


[XMc@sCdZeZddlZddlZddlmZdZddlmZyJddlm	Z	ddlm
Z
ddlmZdd	lmZ
eZWn}eZy dd
lmZddlZWnek
rdZ	nXdZdZd
Z	eZdZ
dZdZ
nXdddYZdZddgZdS(s&
Filesystem-based interprocess mutex.
iN(ttimecCstttdS(Ni(tstrtlongt_uniquefloat(((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pytuniques(trename(tkill(tsymlink(treadlink(tremove(tOpenProcessiiWcCsytdd|WnXtjk
rn}|jdtkr@dS|jdtkrhttjdnn
Xt
ddS(Nis OpenProcess is required to fail.(R
t
pywintypesterrortargstERROR_ACCESS_DENIEDtERROR_INVALID_PARAMETERtOSErrorterrnotESRCHtNonetRuntimeError(tpidtsignalte((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pyR&scCs|dtd}tjj|d}tj|t|d}|j||j|jyt	||Wn$tj
|tj|nXdS(Nt.s.newlinkRtwcb(Rtostpathtjointmkdirt_opentwritetflushtcloseRR	trmdir(tvaluetfilenametnewlinknamet
newvalnametf((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pyR5s





cCsy"ttjj|dd}WnOtk
rs}|jtjksX|jtjkrmt|jdnnX|j
}|j|SdS(NRtrb(RRRRtIOErrorRtENOENTtEIORRtreadR!(R$tfObjRtresult((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pyRDs"$
cCs-tjtjj|dtj|dS(NR(RR	RRR"(R$((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pytrmlinkPstFilesystemLockcBs5eZdZdZeZdZdZdZ	RS(s
    A mutex.

    This relies on the filesystem property that creating
    a symlink is an atomic operation and that it will
    fail if the symlink already exists.  Deleting the
    symlink will release the lock.

    @ivar name: The name of the file associated with this lock.

    @ivar clean: Indicates whether this lock was released cleanly by its
        last owner.  Only meaningful after C{lock} has been called and
        returns True.

    @ivar locked: Indicates whether the lock is currently held by this
        object.
    cCs
||_dS(N(tname(tselfR1((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pyt__init__lscCst}xtry tttj|jWnetk
r}trf|jtj	tj
fkrftS|jtjkryt
|j}Wn_tk
r}|jtjkrq	nn2tk
r}tr|jtj	krtSnXy&tdk	rtt|dnWnvtk
r}|jtjkryt|jWn.tk
rx}|jtjkrrq	nnXt}q	nnXtSnXt|_||_tSWdS(s
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        iN(tTrueRRRtgetpidR1Rt_windowsRtEACCESR+tFalsetEEXISTRR*R)RRtintRR/tlockedtclean(R2R<RR((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pytlockpsJ
	 !		cCsZt|j}t|tjkr@td|jfnt|jt|_dS(s
        Release this lock.

        This deletes the directory with the given name.

        @raise: Any exception os.readlink() may raise, or
        ValueError if the lock is not owned by this process.
        s!Lock %r not owned by this processN(	RR1R:RR5t
ValueErrorR/R8R;(R2R((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pytunlocks
	
N(
t__name__t
__module__t__doc__RR<R8R;R3R=R?(((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pyR0Vs		@cCs>t|}d}z|j}Wd|r8|jnX|S(sDetermine if the lock of the given name is held or not.

    @type name: C{str}
    @param name: The filesystem path to the lock to test

    @rtype: C{bool}
    @return: True if the lock is held, False otherwise.
    N(R0RR=R?(R1tlR.((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pytisLockeds	RD((RBttypet
__metaclass__RRRRRRRRRR	R/R8R6R4twin32apiR
RtImportErrorRRRtfileRR0RDt__all__(((s;/usr/lib/python2.7/dist-packages/twisted/python/lockfile.pyt<module>s8	


			
j