
    Χg                     0    d dl Z d dlZ G d d          ZdS )    Nc                   ,    e Zd ZdZddZd Zd Zd ZdS )		FileBatonz0A primitive, file-based synchronization utility.皙?c                 0    || _         || _        d| _        dS )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      R/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/utils/file_baton.py__init__zFileBaton.__init__	   s     -(    c                     	 t          j        | j        t           j        t           j        z            | _        dS # t          $ r Y dS w xY w)z
        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_acquirezFileBaton.try_acquire   sM    	gd12:	3IJJDG4 	 	 	55	s   6: 
AAc                     t           j                            | j                  r?t	          j        | j                   t           j                            | j                  =dS dS )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   waitzFileBaton.wait#   s_     gnnT011 	*Jt())) gnnT011 	* 	* 	* 	* 	*r   c                 x    | j         t          j        | j                    t          j        | j                   dS )z'Release the baton and removes its file.N)r	   r   closeremover   r   s    r   releasezFileBaton.release-   s5    7HTW
	$%&&&&&r   N)r   )__name__
__module____qualname____doc__r   r   r   r    r   r   r   r      s[        ::     * * *' ' ' ' 'r   r   )r   r   r   r$   r   r   <module>r%      sI    				 ,' ,' ,' ,' ,' ,' ,' ,' ,' ,'r   