o
    Ni                     @   sT   d dl Z d dlZd dlmZ d dlmZ d dlmZ ddlm	Z	 G dd deZdS )	    N)Optional)AcquireReturnProxy)FileLock   )	PathOrStrc                       sL   e Zd ZdZddededdf fdd	Z		
ddee f fddZ	  Z
S )r   a  
    This is just a subclass of the `FileLock` class from the `filelock` library, except that
    it adds an additional argument to the `__init__` method: `read_only_ok`.

    By default this flag is `False`, which an exception will be thrown when a lock
    can't be acquired due to lack of write permissions.
    But if this flag is set to `True`, a warning will be emitted instead of an error when
    the lock already exists but the lock can't be acquired because write access is blocked.
    F	lock_fileread_only_okreturnNc                    s   t  jt||d || _d S )N)timeout)super__init__str_read_only_ok)selfr   r   r	   	__class__ I/home/ubuntu/.local/lib/python3.10/site-packages/cached_path/file_lock.pyr      s   
zFileLock.__init__皙?c              
      sz   zt  jd||d|W S  ty< } z#|jdvr tj| jr7| jr7t	
d| j dt W Y d }~d S  d }~ww )N)r   poll_interval)r         z-Lacking permissions required to obtain lock 'zT'. Race conditions are possible if other processes are writing to the same resource.r   )r   acquireOSErrorerrnoospathisfiler   r   warningswarnUserWarning)r   r   r   kwargserrr   r   r   r      s   
zFileLock.acquire)r   F)Nr   )__name__
__module____qualname____doc__r   boolr   r   r   r   __classcell__r   r   r   r   r      s    
r   )
r   r   typingr   filelockr   r   	_FileLockcommonr   r   r   r   r   <module>   s    