
    g                        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
e      Zd
gZy)    )annotationsN)suppress)EACCESEEXIST)Path   )BaseFileLock)ensure_directory_existsraise_on_not_writable_filec                       e Zd ZdZddZddZy)SoftFileLockz.Simply watches the existence of the lock file.c                   t        | j                         t        | j                         t        j                  t        j
                  z  t        j                  z  t        j                  z  }	 t        j                  | j                  || j                  j                        }|| j                  _        y # t        $ rI}|j                  t        k(  s,|j                  t        k(  rt         j"                  dk(  s Y d }~y Y d }~y d }~ww xY w)Nwin32)r   	lock_filer
   osO_WRONLYO_CREATO_EXCLO_TRUNCopen_contextmodelock_file_fdOSErrorerrnor   r   sysplatform)selfflagsfile_handler	exceptions       C/var/www/openai/venv/lib/python3.12/site-packages/filelock/_soft.py_acquirezSoftFileLock._acquire   s    "4>>2/ KKjjii jj 			6774>>5$--:L:LML *6DMM&  	6)OOv-#,,'2I 3J *	s   /5B6 6	D?:DDc                6   | j                   j                  J t        j                  | j                   j                         d | j                   _        t	        t
              5  t        | j                        j                          d d d        y # 1 sw Y   y xY w)N)	r   r   r   closer   r   r   r   unlink)r   s    r"   _releasezSoftFileLock._release%   sc    }}))555
++,%)"g '') s   "$BBN)returnNone)__name__
__module____qualname____doc__r#   r'        r"   r   r      s    86**r/   r   )
__future__r   r   r   
contextlibr   r   r   r   pathlibr   _apir	   _utilr
   r   r   __all__r.   r/   r"   <module>r6      s6    " 	 
      F*< *B r/   