
    6h                     V    S SK Jr  S SKJr  S SKJr  S SKJr  S SK	J
r
   " S S\5      rg)	    )TracebackType)Optional)Self)FileLock)_WaitCounterc                   l   ^  \ rS rSrSrS\4U 4S jjrS\\\	      S\\	   S\\
   SS4U 4S	 jjrS
rU =r$ )r   
   ab  
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                    > [        S5      R                  5       U l        [        S5      R                  5          [        TU ]  5       nS S S 5        U R                  R	                  5         W$ ! , (       d  f       N*= f)Nzpytorch.filelock.regionzpytorch.filelock.enter)r   guardregion_countersuper	__enter__)selfresult	__class__s     M/var/www/html/shao/venv/lib/python3.13/site-packages/torch/utils/_filelock.pyr   FileLock.__enter__   s^    *+DEKKM2399;W&(F <%%' <;s   A,,
A:exc_type	exc_value	tracebackNc                    > U R                   R                  5         [        S5      R                  5          [        TU ]  XU5        S S S 5        g ! , (       d  f       g = f)Nzpytorch.filelock.exit)r   __exit__r   r   r   )r   r   r   r   r   s       r   r   FileLock.__exit__   sR     	$$&1288: GX)< ;  ;: s   A
A)r   )__name__
__module____qualname____firstlineno____doc__r   r   r   typeBaseExceptionr   r   __static_attributes____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$   