
    JTh                     (    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.c                 *    Xl         X l        SU l        g)z
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()``.
N)lock_file_pathwait_secondsfd)selfr   r   s      N/var/www/auris/envauris/lib/python3.13/site-packages/torch/utils/file_baton.py__init__FileBaton.__init__	   s     -(    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                    [         R                  R                  U R                  5      (       aQ  [        R
                  " U R                  5        [         R                  R                  U R                  5      (       a  MP  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.
N)r   pathexistsr   timesleepr   r   s    r   waitFileBaton.wait#   sJ     ggnnT0011JJt(() 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   N)g?)
__name__
__module____qualname____firstlineno____doc__r   r   r   r"   __static_attributes__ r   r   r   r      s    :*'r   r   )r   r   r   r*   r   r   <module>r+      s    	 ,' ,'r   