
    9i                     0    S SK r S SKrS SKr " S S5      rg)    Nc                   4    \ rS rSrSrS	S jrS rS rS rSr	g)
	FileBaton   z0A primitive, file-based synchronization utility.Nc                 6    Xl         X l        SU l        X0l        g)a.  
Create a new :class:`FileBaton`.

Args:
    lock_file_path: The path to the file used for locking.
    wait_seconds: The seconds to periodically sleep (spin) when
        calling ``wait()``.
    warn_after_seconds: The seconds to wait before showing
        lock file path to warn existing lock file.
N)lock_file_pathwait_secondsfdwarn_after_seconds)selfr   r   r
   s       V/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/torch/utils/file_baton.py__init__FileBaton.__init__
   s     -("4    c                      [         R                  " U R                  [         R                  [         R                  -  5      U l        g! [         a     gf = f)zv
Try to atomically create a file under exclusive access.

Returns:
    True if the file could be created, else False.
TF)osopenr   O_CREATO_EXCLr	   FileExistsErrorr   s    r   try_acquireFileBaton.try_acquire   sA    	ggd112::		3IJDG 		s   AA 
AAc                 
   Sn[         R                   " 5       n[        R                  R                  U R                  5      (       a  [         R
                  " U R                  5        U R                  b`  [         R                   " 5       U-
  U R                  :  a:  U(       d3  [        R                  " SU R                   SU R                   S35        Sn[        R                  R                  U R                  5      (       a  M  gg)z
Periodically sleeps for a certain amount until the baton is released.

The amount of time slept depends on the ``wait_seconds`` parameter
passed to the constructor.
FNzWaited on lock file "z" for z	 seconds.T)
timer   pathexistsr   sleepr   r
   warningswarn)r   
has_warned
start_times      r   waitFileBaton.wait'   s     
YY[
ggnnT0011JJt(()&&299;+d.E.EEjMM$9$:M:M9Nf%)%<%<$=Y#H I!%J ggnnT0011r   c                     U R                   b   [        R                  " U R                   5        [        R                  " U R                  5        g)z'Release the baton and removes its file.N)r	   r   closeremover   r   s    r   releaseFileBaton.release:   s.    77HHTWW
		$%%&r   )r	   r   r   r
   )g?N)
__name__
__module____qualname____firstlineno____doc__r   r   r"   r'   __static_attributes__ r   r   r   r      s    :5 &&'r   r   )r   r   r   r   r/   r   r   <module>r0      s    	  8' 8'r   