
    Ij                        d dl mZ d dl mZ d dlZd dlZ G d de          Z G d de          Z G d d	e          Z G d
 de          Z G d de          Z	 G d de          Z
ej        dk    r5d dlZd dlmc mZ d dlmc mZ d dlmc mZ  e	            Z e            ZdS d dlZ e
            Z e            ZdS )    )ABC)abstractmethodNc                       e Zd Zeed                         Zeed                         Zeed                         Zeed                         ZdS )&_InterProcessReaderWriterLockMechanismc                     d S N )lockfile	exclusives     e/workspace/show-city-briefing-agent/.venv/lib/python3.11/site-packages/fasteners/process_mechanism.pytrylockz._InterProcessReaderWriterLockMechanism.trylock	   	     	    c                     d S r   r	   r
   s    r   unlockz-_InterProcessReaderWriterLockMechanism.unlock   r   r   c                     d S r   r	   paths    r   
get_handlez1_InterProcessReaderWriterLockMechanism.get_handle   r   r   c                     d S r   r	   r   s    r   close_handlez3_InterProcessReaderWriterLockMechanism.close_handle   r   r   N)	__name__
__module____qualname__staticmethodr   r   r   r   r   r	   r   r   r   r      s          ^ \   ^ \   ^ \   ^ \  r   r   c                   Z    e Zd Zeed                         Zeed                         ZdS )_InterProcessMechanismc                     d S r   r	   r   s    r   r   z_InterProcessMechanism.trylock   r   r   c                     d S r   r	   r   s    r   r   z_InterProcessMechanism.unlock$   r   r   N)r   r   r   r   r   r   r   r	   r   r   r   r      s\          ^ \   ^ \  r   r   c                   >    e Zd ZdZed             Zed             ZdS )_WindowsInterProcessMechanismz?Interprocess lock implementation that works on windows systems.c                 n    |                                  }t          j        |t          j        d           d S N   )filenomsvcrtlockingLK_NBLCKr
   r&   s     r   r   z%_WindowsInterProcessMechanism.trylock-   -    ""vv22222r   c                 n    |                                  }t          j        |t          j        d           d S r$   )r&   r'   r(   LK_UNLCKr*   s     r   r   z$_WindowsInterProcessMechanism.unlock2   r+   r   Nr   r   r   __doc__r   r   r   r	   r   r   r"   r"   *   sN        II3 3 \3 3 3 \3 3 3r   r"   c                   >    e Zd ZdZed             Zed             ZdS )_FcntlInterProcessMechanismz=Interprocess lock implementation that works on posix systems.c                 ^    t          j        | t           j        t           j        z             d S r   )fcntllockfLOCK_EXLOCK_NBr   s    r   r   z#_FcntlInterProcessMechanism.trylock;   s#    Hemem;<<<<<r   c                 D    t          j        | t           j                   d S r   r3   r4   LOCK_UNr   s    r   r   z"_FcntlInterProcessMechanism.unlock?       Hem,,,,,r   Nr.   r	   r   r   r1   r1   8   sN        GG= = \= - - \- - -r   r1   c                   j    e Zd ZdZed             Zed             Zed             Zed             ZdS )-_WindowsInterProcessReaderWriterLockMechanismzRInterprocess readers writer lock implementation that works on windows
    systems.c                    |rt           j        t           j        z  }nt           j        }t          j        |                                           }t          j        ||dddt          j        t          j
                                        }|rdS t          j                    }|t          j        k    rdS t          |          )Nr   r%   TF)win32conLOCKFILE_FAIL_IMMEDIATELYLOCKFILE_EXCLUSIVE_LOCKr'   get_osfhandler&   	win32file
LockFileExpointer
pywintypes
OVERLAPPEDGetLastErrorERROR_LOCK_VIOLATIONOSError)r
   r   flagshandleok
last_errors         r   r   z5_WindowsInterProcessReaderWriterLockMechanism.trylockH   s      	769YYEE6E%hoo&7&788!&%Aq):KJLaLcLc:d:dee 	*4"/11JY;;;uj)))r   c           
         t          j        |                                           }t          j        |dddt          j        t          j                                        }|s t          t          j	                              d S )Nr   r%   )
r'   rA   r&   rB   UnlockFileExrD   rE   rF   rI   rG   )r
   rK   rL   s      r   r   z4_WindowsInterProcessReaderWriterLockMechanism.unlock[   sq    %hoo&7&788#FAq!Y5FzG\G^G^5_5_`` 	4)022333	4 	4r   c                 "    t          | d          S Nza+openr   s    r   r   z8_WindowsInterProcessReaderWriterLockMechanism.get_handleb       D$r   c                 .    |                                   d S r   closer   s    r   r   z:_WindowsInterProcessReaderWriterLockMechanism.close_handlef       r   N	r   r   r   r/   r   r   r   r   r   r	   r   r   r<   r<   D   s          * * \*$ 4 4 \4     \    \  r   r<   c                   j    e Zd ZdZed             Zed             Zed             Zed             ZdS )+_FcntlInterProcessReaderWriterLockMechanismzPInterprocess readers writer lock implementation that works on posix
    systems.c                    |rt           j        t           j        z  }nt           j        t           j        z  }	 t          j        | |           dS # t
          t          f$ r,}|j        t          j        t          j	        fv rY d }~dS |d }~ww xY w)NTF)
r3   r5   r6   LOCK_SHr4   IOErrorrI   errnoEACCESEAGAIN)r
   r   rJ   es       r   r   z3_FcntlInterProcessReaderWriterLockMechanism.trylocko   s      	2MEM1EEMEM1E	K%(((4! 	 	 	w5<666uuuuu		s   A BBBBc                 D    t          j        | t           j                   d S r   r8   r   s    r   r   z2_FcntlInterProcessReaderWriterLockMechanism.unlock   r:   r   c                 "    t          | d          S rQ   rR   r   s    r   r   z6_FcntlInterProcessReaderWriterLockMechanism.get_handle   rT   r   c                 .    |                                   d S r   rV   r   s    r   r   z8_FcntlInterProcessReaderWriterLockMechanism.close_handle   rX   r   NrY   r	   r   r   r[   r[   k   s            \  - - \-     \    \  r   r[   nt)abcr   r   r_   osr   r   r"   r1   r<   r[   namer'   fasteners.pywin32.pywintypespywin32rE   fasteners.pywin32.win32conr>   fasteners.pywin32.win32filerB   %_interprocess_reader_writer_mechanism_interprocess_mechanismr3   r	   r   r   <module>rp      s                				    S   .	 	 	 	 	S 	 	 	3 3 3 3 3$: 3 3 3	- 	- 	- 	- 	-"8 	- 	- 	-$ $ $ $ $4Z $ $ $N    2X   D 7d??MMM555555555111111111333333333,Y,Y,[,[);;== LLL,W,W,Y,Y)99;;r   