+
    Dfj*                        R t ^ RIt^ RIt^ RIHt ^ RIHt R t^ RIHt ]P                  ! 4       '       g   ^ RIH
t
HtHtHt RtMRt ^ RIt^ R	IHt ^t^WtR
 t
]tR tR tR t ! R R4      tR tRR.tR#   ] d    Rt
 L)i ; i)z&
Filesystem-based interprocess mutex.
N)time)platformc                  H    \        \        \        4       R ,          4      4      # )i  )strint_uniquefloat     9/usr/lib/python3/dist-packages/twisted/python/lockfile.pyuniquer      s    s<>D()**r	   )rename)killreadlinkremovesymlinkFT)OpenProcessc                      \        ^ ^ V 4       \        R4      h  \        P                   d_   pTP                  ^ ,          \
        8X  d    Rp?R# TP                  ^ ,          \        8X  d   \        \        P                  R4      hh Rp?ii ; i)    z OpenProcess is required to fail.N)
r   RuntimeError
pywintypeserrorargsERROR_ACCESS_DENIEDERROR_INVALID_PARAMETEROSErrorerrnoESRCH)pidsignales   && r
   r   r   4   ss    	GAq#& ##EFF ## 66!9 33VVAY"99!%++t44s    BB7BBc                   VR,           \        4       ,           R,           p\        P                  P                  VR4      p\        P                  ! V4       Rp\        W44      ;_uu_ 4       pVP                  V 4       VP                  4        RRR4        \        W!4       R#   + '       g   i     L; i  \         d/    \        P                  ! T4       \        P                  ! T4       h i ; i)zr
Write a file at C{filename} with the contents of C{value}. See the
above comment block as to why this is needed.
.z.newlinkr   wN)r   ospathjoinmkdir_openwriteflushr   BaseExceptionr   rmdir)valuefilenamenewlinkname
newvalnamemodefs   &&    r
   r   r   E   s     nvx/*<WW\\+y9

 :$$GGENGGI %	;) %$  	IIj!HH[!	s   +"B#B6 #B3	69C/c                    \        \        P                  P                  V R4      R4      pV;_uu_ 4        VP	                  4       pRRR4       V#   + '       g   i     X# ; i  \
         d[   pTP                  \        P                  8X  g    TP                  \        P                  8X  d   \        TP                  R4      hh Rp?ii ; i)zY
Read the contents of C{filename}. See the above comment block as to why
this is needed.
r   rN)	r'   r#   r$   r%   readr   r   ENOENTEIO)r-   fObjresultr   s   &   r
   r   r   `   s    
		h	:C@D  M M  	ww%,,&!''UYY*>aggt,,	s#   *A% AA"	%C
0ACC
c                     \         P                  ! \         P                  P                  V R 4      4       \         P                  ! V 4       R# )r   N)r#   r   r$   r%   r+   )r-   s   &r
   rmlinkr:   r   s)    
		"'',,x34
r	   c                   >   a  ] tR t^wt o RtRtRtR tR tR t	Rt
V tR# )FilesystemLocka  
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.
NFc                    Wn         R # )N)name)selfr>   s   &&r
   __init__FilesystemLock.__init__   s    	r	   c                   Rp  \        \        \        P                  ! 4       4      V P                  4       RT n        Yn        R#   \
         Ed   p\        '       d6   TP                  \        P                  \        P                  39   d    Rp?R# TP                  \        P                  8X  EdH    \        T P                  4      pMr  \
         de   pTP                  \        P                  8X  d    Rp? Rp?K  \        '       d*   TP                  \        P                  8X  d    Rp? Rp?R# h Rp?ii ; i \        e   \        \        T4      ^ 4       M  \
         d   pTP                  \        P                  8X  dg    \!        T P                  4       MB  \
         d5   pTP                  \        P                  8X  d    Rp? Rp? Rp?EK  h Rp?ii ; iRp Rp? Rp?EK  h Rp?ii ; i Rp?R# h Rp?ii ; i)z
Acquire this lock.

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

@raise OSError: Any exception L{os.symlink()} may raise,
    other than L{errno.EEXIST}.
TNF)r   r   r#   getpidr>   r   _windowsr   EACCESr6   EEXISTr   r5   r   r   r   r:   lockedclean)r?   rH   r   r   s   &   r
   lockFilesystemLock.lock   se    ,BIIK($))4X DKJ[  *8ELL%))+D D !77ell*&tyy1" 77ell2 %H%X!''U\\*A $)5+ S1-" 77ekk1& &tyy 1#* &#$77ell#: %-H %& %*E$H  !U*s   2A H ;G; G;4C
	G;
D9D44G;>D4
D4)G;3D44D99G;=EG;G1&G,FG,G'GG,
G;GGG, G;+G,,G11G;:G;;H c                    \        V P                  4      p\        V4      \        P                  ! 4       8w  d   \        RV P                  : R24      h\        V P                  4       RV n        R# )z
Release this lock.

This deletes the directory with the given name.

@raise OSError: Any exception L{os.readlink()} may raise.
@raise ValueError: If the lock is not owned by this process.
zLock z not owned by this processFN)r   r>   r   r#   rC   
ValueErrorr:   rG   )r?   r   s   & r
   unlockFilesystemLock.unlock   sP     tyy!s8ryy{"uTYYM1KLMMtyyr	   )rH   rG   r>   )__name__
__module____qualname____firstlineno____doc__rH   rG   r@   rI   rM   __static_attributes____classdictcell__)__classdict__s   @r
   r<   r<   w   s+     $ EF;z r	   r<   c                    \        V 4      pRp VP                  4       pV'       d   VP                  4        V'       * #   T'       d   TP                  4        i i ; i)z
Determine 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)r<   rI   rM   )r>   lr8   s   &  r
   isLockedrY      sL     	tAFHHJ: HHJ s	   > ArY   )rS   r   r#   r   r   twisted.python.runtimer   r   r   	isWindowsr   r   r   r:   r   rD   r   win32apir   r   r   ImportErroropenr'   r<   rY   __all__r   r	   r
   <module>r`      s   
  	 % ++ <<HHG(  "$
	G E6$
c cL( Z
(K  s   	
A8 8	BB