
                         R    S SK r S SKrS SKrS SKJr   " S S\R
                  5      rg)    N)locked_filec                   $    \ rS rSrSrS rS rSrg)_FcntlOpener   z0Open, lock, and unlock a file using fcntl.lockf.c                    U R                   (       a/  [        R                  " SR                  U R                  5      5      e[
        R
                  " 5       n[        R                  " U R                  5         [        U R                  U R                  5      U l	          [        R                   " U R                  R#                  5       [        R$                  5        SU l         g! [         ab  nUR                  [        R                  [        R                  4;   a*  [        U R                  U R                  5      U l	         SnAg SnANSnAff = f! [         a  nUS:X  a  e UR                  [        R                  :w  a  e [
        R
                  " 5       U-
  U:  a  [        R&                  R)                  SU R                  U5        U R                  (       a  U R                  R+                  5         [        U R                  U R                  5      U l	         SnAg[
        R,                  " U5         SnAOSnAff = fGM  )aX  Open the file and lock it.

Args:
    timeout: float, How long to try to lock for.
    delay: float, How long to wait between retries

Raises:
    AlreadyLockedException: if the lock is already acquired.
    IOError: if the open fails.
    CredentialsFileSymbolicLinkError: if the file is a symbolic
                                      link.
zFile {0} is already lockedNTr   zCould not lock %s in %s seconds)_lockedr   AlreadyLockedExceptionformat	_filenametimevalidate_fileopen_mode_fhIOErrorerrnoEPERMEACCES_fallback_modefcntllockffilenoLOCK_EXloggerwarnclosesleep)selftimeoutdelay
start_timees        5lib/third_party/oauth2client/contrib/_fcntl_opener.pyopen_and_lock_FcntlOpener.open_and_lock   s    <<44,33DNNCE EYY[
!!$..1	DNNDJJ7DH "DHHOO-u}}=#  	 ww5;;550C0CD 6	  "a<77ell*IIK*,8&&++,M,0NNGExx(#DNND4G4GHDH

5!!" s9   7%C# AE #
E-AE

E
H>B=H9H99H>c                    U R                   (       a=  [        R                  " U R                  R	                  5       [        R
                  5        SU l         U R                  (       a  U R                  R                  5         gg)z:Close and unlock the file using the fcntl.lockf primitive.FN)r   r   r   r   r   LOCK_UNr   )r   s    r#   unlock_and_close_FcntlOpener.unlock_and_closeK   sG    <<KK)5==988HHNN     )r   r   N)__name__
__module____qualname____firstlineno____doc__r$   r(   __static_attributes__ r*   r#   r   r      s    :0"dr*   r   )r   r   r   oauth2client.contribr   _Openerr   r1   r*   r#   <module>r4      s%       ,;;&& ;r*   