a
    h                     @   sP   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 deZdS )	    )TracebackType)Optional)Self)FileLock)_WaitCounterc                       sN   e Zd ZdZed fddZeee  ee ee	 dd 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:0    Y  | j  |S )Nzpytorch.filelock.regionzpytorch.filelock.enter)r   guardregion_countersuper	__enter__)selfresult	__class__ C/var/www/auris/lib/python3.9/site-packages/torch/utils/_filelock.pyr      s
    (
zFileLock.__enter__N)exc_type	exc_value	tracebackr   c                    sJ   | j   td   t ||| W d    n1 s<0    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   r   typeBaseExceptionr   r   __classcell__r   r   r   r   r   
   s   	
r   N)typesr   typingr   Ztyping_extensionsr   Zfilelockr   Zbase_FileLockZtorch.monitorr   r   r   r   r   <module>   s
   