a
    &ñ»j¯  ã                   @  sz   d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
 ddlmZ ddlmZmZ G d	d
„ d
eƒZd
gZdS )é    )ÚannotationsN)Úsuppress)ÚEACCESÚEEXIST)ÚPathé   )ÚBaseFileLock)Úensure_directory_existsÚraise_on_not_writable_filec                   @  s,   e Zd ZdZddœdd„Zddœdd„ZdS )	ÚSoftFileLockz.Simply watches the existence of the lock file.ÚNone)Úreturnc              
   C  s–   t | jƒ t| jƒ tjtjB tjB tjB }zt | j|| j	j
¡}W nD tyˆ } z,|jtkst|jtkrrtjdkst‚ W Y d }~nd }~0 0 || j	_d S )NÚwin32)r
   Ú	lock_filer	   ÚosÚO_WRONLYÚO_CREATÚO_EXCLÚO_TRUNCÚopenÚ_contextÚmodeÚOSErrorÚerrnor   r   ÚsysÚplatformÚlock_file_fd)ÚselfÚflagsÚfile_handlerÚ	exception© r!   ú4E:\soccer\ml_env\Lib\site-packages\filelock/_soft.pyÚ_acquire   s*    

ÿþýÿÿþþzSoftFileLock._acquirec                 C  s`   | j jd usJ ‚t | j j¡ d | j _ttƒ� t| jƒ ¡  W d   ƒ n1 sR0    Y  d S )N)	r   r   r   Úcloser   r   r   r   Úunlink)r   r!   r!   r"   Ú_release%   s
    
zSoftFileLock._releaseN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   r&   r!   r!   r!   r"   r      s   r   )Ú
__future__r   r   r   Ú
contextlibr   r   r   r   Úpathlibr   Z_apir   Z_utilr	   r
   r   Ú__all__r!   r!   r!   r"   Ú<module>   s   !ÿ