o
    $i                     @   sF   d dl Z d dlZd dlmZ d dlmZ d dlZdZG dd dZdS )    N)Path)FileLock_ray_lockfilesc                   @   s6   e Zd ZdZdefddZdd Zdd Zd	d
 ZdS )TempFileLocka  FileLock wrapper that uses temporary file locks.

    The temporary directory that these locks are saved to can be configured via
    the `RAY_TMPDIR` environment variable.

    Args:
        path: The file path that this temporary file lock is used for.
            This will be used to generate the lockfile filename.
            Ex: For concurrent writes to a file, this is the common filepath
            that multiple processes are writing to.
        **kwargs: Additional keyword arguments to pass to the underlying `FileLock`.
    pathc                 K   s   || _ ttjj  }|t | _t	
tt| j  d | _| j| j d | _tjt| jdd t| jfi || _d S )Nzutf-8z.lockT)exist_ok)r   r   ray_commonutilsget_user_temp_dirresolveRAY_LOCKFILE_DIR	_lock_dirhashlibsha1strencode	hexdigest
_path_hash
_lock_pathosmakedirsr   _lock)selfr   kwargstemp_dir r   W/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/ray/air/_internal/filelock.py__init__   s   
zTempFileLock.__init__c                 C   s   | j   | S N)r   acquire)r   r   r   r   	__enter__&   s   
zTempFileLock.__enter__c                 C   s   | j   d S r   )r   release)r   typevalue	tracebackr   r   r   __exit__*   s   zTempFileLock.__exit__c                 C   s   t | j|S r   )getattrr   )r   namer   r   r   __getattr__-   s   zTempFileLock.__getattr__N)	__name__
__module____qualname____doc__r   r   r!   r&   r)   r   r   r   r   r      s    r   )	r   r   pathlibr   filelockr   r   r   r   r   r   r   r   <module>   s    