
    i                     J    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)Self)FileLock)_WaitCounterc                   \     e Zd ZdZdef fdZdee   dz  dedz  dedz  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     O/var/www/html/engine/venv/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_typeN	exc_value	tracebackc                     | 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   typeBaseExceptionr   r   __classcell__)r   s   @r   r   r   	   sX    	4 }%, !4' !4'	
 
     r   N)	typesr   typing_extensionsr   filelockr   base_FileLocktorch.monitorr    r   r   <module>r%      s     " . & }  r   