
     i                    4   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZ ddlmZ dd	lmZ d
Zej        dk    r G d de          Zn=	 d dlZej        ej        ej        ej        fZdZn# eef$ r Y nw xY w G d de          ZddgZdS )    )annotationsN)suppress)EAGAINENOSYSEWOULDBLOCK)Path)cast   )BaseFileLock)ensure_directory_existsFwin32c                  "    e Zd ZdZddZddZdS )UnixFileLockzHUses the :func:`fcntl.flock` to hard lock the lock file on unix systems.returnNonec                    t           NNotImplementedErrorselfs    X/srv/www/vhosts/g4struct/public_html/venv/lib/python3.11/site-packages/filelock/_unix.py_acquirezUnixFileLock._acquire       %%    c                    t           r   r   r   s    r   _releasezUnixFileLock._release   r   r   Nr   r   )__name__
__module____qualname____doc__r   r    r   r   r   r      sB        VV	& 	& 	& 	&	& 	& 	& 	& 	& 	&r   r   Tc                  *    e Zd ZdZddZddZddZdS )	r   a0  
        Uses the :func:`fcntl.flock` to hard lock the lock file on unix systems.

        Lock file cleanup: Unix and macOS delete the lock file reliably after release, even in
        multi-threaded scenarios. Unlike Windows, Unix allows unlinking files that other processes
        have open.
        r   r   c                   t          | j                   t          j        t          j        z  }t          t          dd           }|||z  }|t          j        z  }|                                 }	 t          j        | j        ||          }n# t          $ r7 | j        r.t          | j                  j                                        rY d S  t          $ rg t          | j                                                  s 	 t          j        | j        |t          j         z  |          }n# t          $ r Y Y d S w xY wY nw xY w| j        rKt          t                    5  t          j        || j        j                   d d d            n# 1 swxY w Y   	 t'          j        |t&          j        t&          j        z             t          j        |          j        dk    rt          j        |           d S || j        _        d S # t6          $ r}t          j        |           |j        t:          k    rt          t6                    5  t          | j                                                   d d d            n# 1 swxY w Y   |                                  |                                   Y d }~d S |j        tB          tD          hvr Y d }~d S d }~ww xY w)N
O_NOFOLLOWr   )#r   	lock_fileosO_RDWRO_TRUNCgetattrO_CREAT
_open_modeopenFileNotFoundErrorr   parentexistsPermissionErrorhas_explicit_moder   fchmod_contextmodefcntlflockLOCK_EXLOCK_NBfstatst_nlinkcloselock_file_fdOSErrorerrnor   unlink_fallback_to_soft_lockr   r   r   )r   
open_flags
o_nofollow	open_modefd	exceptions         r   r   zUnixFileLock._acquire.   s>   #DN333RZ/J \488J%j(
"*$J))IWT^ZCC$    > d4>&:&:&A&H&H&J&J FF"    DN++2244 rzk1I9UUBB(   FFF B % 6o.. 6 6Ib$-"45556 6 6 6 6 6 6 6 6 6 6 6 6 6 64B =>>> 8B<<(A--HRLLLLL13DM...!  	 	 	?f,,!'** 6 6T^,,335556 6 6 6 6 6 6 6 6 6 6 6 6 6 6//111MMOOOFFFFF?6;*??? @?????	s   /B <D;
1D;<)D&%D;&
D50D;4D55D;:D; FF	F	,G> >
K8K 'I3'K3I7	7K:I7	;+K,KKc                    ddl m} t          j        dd           ddlm}m} t          | |          r|n|| _        d S )Nr
   )SoftFileLockzDflock not supported on this filesystem, falling back to SoftFileLock   )
stacklevel)AsyncSoftFileLockBaseAsyncFileLock)	_softrI   warningswarnasynciorL   rM   
isinstance	__class__)r   rI   rL   rM   s       r   rB   z#UnixFileLock._fallback_to_soft_lock_   se    ++++++M`mnooooEEEEEEEE2<TCT2U2Ug..[gDNNNr   c                   t          d| j        j                  }d | j        _        t          t                    5  t          | j                                                   d d d            n# 1 swxY w Y   t          j	        |t          j
                   t          t                    5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nint)r	   r5   r>   r   r?   r   r'   rA   r7   r8   LOCK_UNr(   r=   )r   rF   s     r   r   zUnixFileLock._releaseg   s2   eT]788B)-DM&'"" . .T^$$++---. . . . . . . . . . . . . . .KEM***'""                   s#   'A..A25A2,CCCNr   )r   r    r!   r"   r   rB   r   r#   r   r   r   r   %   s_        	 	/	4 /	4 /	4 /	4b	h 	h 	h 	h	 	 	 	 	 	r   	has_fcntl)
__future__r   r(   sysrO   
contextlibr   r@   r   r   r   pathlibr   typingr	   _apir   _utilr   rW   platformr   r7   r8   r9   r:   rV   _ImportErrorAttributeError__all__r#   r   r   <module>rd      s   " " " " " " 				 



        - - - - - - - - - -                   * * * * * * 	<7& & & & &| & & & &[%-F 		 (   
I I I I I| I I IZ s   A9 9BB