o
    i                     @   sD   d dl mZ d dlmZ d dlmZ d dlmZ G dd deZdS )    )TracebackType)Self)FileLock)_WaitCounterc                       sT   e Zd ZdZdef fddZdee dB dedB dedB ddf fd	d
Z	  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                    sR   t d | _t d  t  }W d    n1 sw   Y  | j  |S )Nzpytorch.filelock.regionzpytorch.filelock.enter)r   guardregion_countersuper	__enter__)selfresult	__class__ W/sda-disk/www/egybert/egybert_env/lib/python3.10/site-packages/torch/utils/_filelock.pyr
      s   
zFileLock.__enter__exc_typeN	exc_value	tracebackc                    sL   | j   td  t ||| W d    d S 1 sw   Y  d S )Nzpytorch.filelock.exit)r   __exit__r   r   r	   )r   r   r   r   r   r   r   r      s   

zFileLock.__exit__)__name__
__module____qualname____doc__r   r
   typeBaseExceptionr   r   __classcell__r   r   r   r   r   	   s    
r   N)	typesr   typing_extensionsr   filelockr   base_FileLocktorch.monitorr   r   r   r   r   <module>   s
    