o
    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                       sT   e Zd ZdZdef fddZdeee  dee dee	 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__ i/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/utils/_filelock.pyr      s   
zFileLock.__enter__exc_type	exc_value	tracebackNc                    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   r   typeBaseExceptionr   r   __classcell__r   r   r   r   r   
   s    
r   N)typesr   typingr   typing_extensionsr   filelockr   base_FileLocktorch.monitorr   r   r   r   r   <module>   s    