
    Yh                     8    d dl Z 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.皙?Nc                 >    || _         || _        d| _        || _        dS )an  
        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       h/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/torch/utils/file_baton.py__init__zFileBaton.__init__
   s)     -("4    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                    d}t          j                     }t          j                            | j                  rt          j        | j                   | j        Ht          j                     |z
  | j        k    r)|s't          j	        d| j         d| j         d           d}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.
        FNzWaited on lock file "z" for z	 seconds.T)
timer   pathexistsr   sleepr   r
   warningswarn)r   
has_warned
start_times      r   waitzFileBaton.wait'   s     
Y[[
gnnT011 	&Jt()))&29;;+d.EEEjEM #H$:M #H #H%)%<#H #H #H I I I!%J 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   )r   N)__name__
__module____qualname____doc__r   r   r    r$    r   r   r   r      s[        ::5 5 5 5   & & &&' ' ' ' 'r   r   )r   r   r   r   r)   r   r   <module>r*      sR    				  8' 8' 8' 8' 8' 8' 8' 8' 8' 8'r   