
    Vh                     V    d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
  G d de      Zy)	    )TracebackType)Optional)Self)FileLock)_WaitCounterc                   \     e Zd ZdZdef fdZdeee      dee   dee	   ddf fdZ
 xZS )	r   a~  
    This behaves like a normal file lock.

    However, it adds waitcounters for acquiring and releasing the filelock
    as well as for the critical region within it.

    pytorch.filelock.enter - While we're acquiring the filelock.
    pytorch.filelock.region - While we're holding the filelock and doing work.
    pytorch.filelock.exit - While we're releasing the filelock.
    returnc                     t        d      j                         | _        t        d      j                         5  t        |          }d d d        | j                  j	                          S # 1 sw Y   %xY w)Nzpytorch.filelock.regionzpytorch.filelock.enter)r   guardregion_countersuper	__enter__)selfresult	__class__s     E/home/dcms/DCMS/lib/python3.12/site-packages/torch/utils/_filelock.pyr   zFileLock.__enter__   se    *+DEKKM2399; 	)W&(F	)%%'	) 	)s   A,,A5exc_type	exc_value	tracebackNc                     | j                   j                          t        d      j                         5  t        |   |||       d d d        y # 1 sw Y   y xY w)Nzpytorch.filelock.exit)r   __exit__r   r   r   )r   r   r   r   r   s       r   r   zFileLock.__exit__   sV     	$$&1288: 	= GXy)<	= 	= s   AA)__name__
__module____qualname____doc__r   r   r   typeBaseExceptionr   r   __classcell__)r   s   @r   r   r   
   sX    	4 4./ M* M*	
 
     r   N)typesr   typingr   typing_extensionsr   filelockr   base_FileLocktorch.monitorr    r   r   <module>r'      s       " . & }  r   