Ë ÅÉY…ë &ãóz—ddlmZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z ddlmZmZddlmZdd lmZer&ddlZdd lmZej0d k\rdd lmZndd lmZej6d «ZGd„d«Ze Gd„d««ZGd„dee «ZGd„deej@«Z!ddgZ"y)é)Ú annotationsN)ÚABCÚabstractmethod)Ú dataclass)Úlocal)Ú TYPE_CHECKINGÚAny)ÚWeakValueDictionaryé)ÚTimeout)Ú TracebackType)éé )ÚSelfÚfilelockcó8—eZdZdZdd„Zdd„Z dd„Zy) ÚAcquireReturnProxyzDA context-aware object that will release the lock file when exiting.có—||_y©N©Úlock)Úselfrs ú2/usr/lib/python3.12/site-packages/filelock/_api.pyÚ__init__zAcquireReturnProxy.__init__#s €Øˆ� ócó—|jSrr©rs rÚ __enter__zAcquireReturnProxy.__enter__&s €Ø�y‰yÐrcó8—|jj«yr)rÚrelease©rÚexc_typeÚ exc_valueÚ tracebacks rÚ__exit__zAcquireReturnProxy.__exit__)s€ð � ‰ ×ÑÕrN)rÚ BaseFileLockÚreturnÚNone)r'r&©r"ztype[BaseException] | Noner#zBaseException | Noner$zTracebackType | Noner'r()Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr%©rrrr s:„ÙNóóðà,ðð(ðð(ð ð ô rrcóL—eZdZUdZded<ded<ded<dZd ed <d Zded <y) ÚFileLockContextzBA dataclass which holds the context for a ``BaseFileLock`` object.ÚstrÚ lock_fileÚfloatÚtimeoutÚintÚmodeNz int | NoneÚ lock_file_fdrÚ lock_counter)r*r+r,r-Ú__annotations__r7r8r.rrr0r02s2…áLð ƒNðƒNð ƒIð $€L�*Ó#ð€L�#Ôrr0có—eZdZdZy)ÚThreadLocalFileContextz8A thread local version of the ``FileLockContext`` class.N)r*r+r,r-r.rrr;r;Is„ÚBrr;c󨇗eZdZUdZded< dddœ dˆfd„Zdˆfd„ Z dddœ dd „Zdd „Ze dd „«Z e d d „«Z e d!d „«Z e jd"d„«Z e d#d„«Zed$d„«Zed$d„«Ze dd„«Ze d#d„«Z d%dddœ d&d„Zd'd(d„Zd)d„Z d*d„Zd$d„ZˆxZS)+r&z+Abstract base class for a file lock object.z&WeakValueDictionary[str, BaseFileLock]Ú _instancesTF)Ú is_singletonc ó•—|st‰ |�|«S|jjt |««}|s)t‰ |�|«}||jt |«<|S||j k7s||j k7r d}t|«‚|S)zYCreate a new lock object or if specified return the singleton instance for the lock file.zGSingleton lock instances cannot be initialized with differing arguments)ÚsuperÚ__new__r=Úgetr1r4r6Ú ValueError) Úclsr2r4r6Ú thread_localr>ÚkwargsÚinstanceÚmsgÚ __class__s €rrAzBaseFileLock.__new__Rsˆø€ñÜ‘7‘? 3Ó'Ð 'à—>‘>×%Ñ%¤c¨)£nÓ5ˆÙÜ‘w‘ sÓ+ˆHØ-5ˆC�N‰Nœ3˜y›>Ñ *ð ˆð ˜×(Ñ(Ò (¨D°H·M±MÒ,AØ[ˆCܘS“/Ð !àˆrc óB•—t‰|�di|¤Žt«|_y)z'Setup unique state for lock subclasses.Nr.)r@Ú__init_subclass__r r=)rDrFrIs €rrKzBaseFileLock.__init_subclass__jsø€ä ‰Ñ!Ñ+ FÒ+Ü,Ó.ˆ�rcó„—||_||_tj|«||dœ}|rtnt di|¤Ž|_y)a® Create a new lock object. :param lock_file: path to the file :param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in the acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it to a negative value. A timeout of 0 means that there is exactly one attempt to acquire the file lock. :param mode: file permissions for the lockfile :param thread_local: Whether this object's internal context should be thread local or not. If this is set to ``False`` then the lock will be reentrant across threads. :param is_singleton: If this is set to ``True`` then only one instance of this class will be created per lock file. This is useful if you want to use the lock object for reentrant locking without needing to pass the same object around. )r2r4r6Nr.)Ú_is_thread_localÚ _is_singletonÚosÚfspathr;r0Ú_context)rr2r4r6rEr>rFs rrzBaseFileLock.__init__osJ€ð0!-ˆÔØ)ˆÔô Ÿ™ 9Ó-ØØñ" ˆð +fÁLÕ*@ÔVeÑ)pÐioÑ)pˆ� rcó—|jS)z>:return: a flag indicating if this lock is thread local or not)rMrs rÚis_thread_localzBaseFileLock.is_thread_local“s€à×$Ñ$Ð$rcó—|jS)z;:return: a flag indicating if this lock is singleton or not)rNrs rr>zBaseFileLock.is_singleton—s€ð×!Ñ!Ð!rcó.—|jjS)z:return: path to the lock file)rQr2rs rr2zBaseFileLock.lock_fileœs€ð�}‰}×&Ñ&Ð&rcó.—|jjS)za :return: the default timeout value, in seconds .. versionadded:: 2.0.0 )rQr4rs rr4zBaseFileLock.timeout¡s€ð�}‰}×$Ñ$Ð$rcó8—t|«|j_y)ze Change the default timeout value. :param value: the new value, in seconds N)r3rQr4)rÚvalues rr4zBaseFileLock.timeoutªs€ô!& e£ ˆ� ‰ Õrcó.—|jjS)z.:return: the file permissions for the lockfile)rQr6rs rr6zBaseFileLock.mode´s€ð�}‰}×!Ñ!Ð!rcó—t‚)zjIf the file lock could be acquired, self._context.lock_file_fd holds the file descriptor of the lock file.©ÚNotImplementedErrorrs rÚ_acquirezBaseFileLock._acquire¹ó €ô"Ð!rcó—t‚)z>Releases the lock and sets self._context.lock_file_fd to None.r[rs rÚ_releasezBaseFileLock._release¾r^rcó2—|jjduS)zÄ :return: A boolean indicating if the lock file is holding the lock currently. .. versionchanged:: 2.0.0 This was previously a method and is now a property. N)rQr7rs rÚ is_lockedzBaseFileLock.is_lockedÃs€ð�}‰}×)Ñ)°Ð5Ð5rcó.—|jjS)zP:return: The number of times this lock has been acquired (but not yet released).)rQr8rs rr8zBaseFileLock.lock_counterÏs€ð�}‰}×)Ñ)Ð)rN)Úpoll_intervallÚblockingcóŒ—|€|jj}|� d}tj|td¬«|}|jxj dz c_t |«}|j}tj«} |js'tjd||«|j«|jrtjd||«n›|dur"tjd||«t|«‚d |cxkrtj«|z kr%nn"tjd ||«t|«‚d }tj||||«tj|«Œò t%|¬ «S#t $r4t#d |jj dz «|j_‚wxYw) a_ Try to acquire the file lock. :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired :param poll_interval: interval of trying to acquire the lock file :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired. :raises Timeout: if fails to acquire lock within the timeout period :return: a context object that will unlock the file when the context is exited .. code-block:: python # You can use this method in the context manager (recommended) with lock.acquire(): pass # Or use an equivalent try-finally construct: lock.acquire() try: pass finally: lock.release() .. versionchanged:: 2.0.0 This method returns now a *proxy* object instead of *self*, so that it can be used in a with statement without side effects. z+use poll_interval instead of poll_intervallé)Ú stacklevelr z#Attempting to acquire lock %s on %szLock %s acquired on %sFz+Failed to immediately acquire lock %s on %srz"Timeout on acquiring lock %s on %sz2Lock %s not acquired on %s, waiting %s seconds ...r)rQr4ÚwarningsÚwarnÚDeprecationWarningr8Úidr2ÚtimeÚ perf_counterrbÚ_LOGGERÚdebugr]r ÚsleepÚ BaseExceptionÚmaxr) rr4Ú poll_intervalrdrerHÚlock_idÚ lock_filenameÚ start_times rÚacquirezBaseFileLock.acquireÔs„€ðP ˆ?Ø—m‘m×+Ñ+ˆGà Ð %Ø?ˆCÜ �M‰M˜#Ô1¸aÕ @Ø*ˆMð � ‰ ×"Ò" aÑ'Õ"ä�T“(ˆØŸ™ˆ Ü×&Ñ&Ó(ˆ ð ØØ—~’~Ü—M‘MÐ"GÈÐR_Ô`Ø—M‘M”OØ—>’>Ü—M‘MÐ":¸GÀ]ÔSØØ˜uÑ$Ü—M‘MÐ"OÐQXÐZgÔhÜ! -Ó0Ð0ؘÔB¤$×"3Ñ"3Ó"5¸ Ñ"BÕBÜ—M‘MÐ"FÈÐQ^Ô_Ü! -Ó0Ð0ØJ�Ü— ‘ ˜c 7¨M¸=ÔIÜ— ‘ ˜=Ô)ðð ô" tÔ,Ð,øôò Ü),¨Q°· ± ×0JÑ0JÈQÑ0NÓ)OˆD�M‰MÔ &Ø ð ús ÂC3FÆ=Gcó`—|jr¢|jxjdzc_|jjdk(s|rgt|«|j}}t j d||«|j«d|j_t j d||«yyy)a+ Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also note, that the lock file itself is not automatically deleted. :param force: If true, the lock counter is ignored and the lock is released in every case/ r rz#Attempting to release lock %s on %szLock %s released on %sN)rbrQr8rlr2rorpr`)rÚforcerurvs rr zBaseFileLock.release s†€ð �>Š>Ø �M‰M× &Ò &¨!Ñ +Õ &à�}‰}×)Ñ)¨QÒ.±%Ü)+¨D«°4·>±>˜�ä— ‘ ÐCÀWÈmÔ\Ø— ‘ ”Ø-.�— ‘ Ô*Ü— ‘ Ð6¸ÀÕOð 38ð rcó&—|j«|S)zF Acquire the lock. :return: the lock object )rxrs rrzBaseFileLock.__enter__3s€ð � ‰ ŒØˆ rcó$—|j«y)zÏ Release the lock. :param exc_type: the exception type if raised :param exc_value: the exception value if raised :param traceback: the exception traceback if raised N©r r!s rr%zBaseFileLock.__exit__=s €ð � ‰ �rcó(—|jd¬«y)z'Called when the lock object is deleted.T)rzNr}rs rÚ__del__zBaseFileLock.__del__Ms€à � ‰ ˜4ˆ Õ r)éÿÿÿÿi¤T)r2ústr | os.PathLike[str]r4r3r6r5rEÚboolr>r‚rFúdict[str, Any]r'r)rFrƒr'r() r2r�r4r3r6r5rEr‚r>r‚r'r()r'r‚)r'r1)r'r3)rXz float | strr'r()r'r5)r'r()Ngš™™™™™©?) r4ú float | Nonertr3rdr„rer‚r'r)F)rzr‚r'r()r'rr))r*r+r,r-r9rArKrrSÚpropertyr>r2r4Úsetterr6rr]r`rbr8rxr rr%rÚ __classcell__)rIs@rr&r&Msø…Ù5à6Ó6ð ØØ!ð ð#ñà)ððððð ð ð ððð!ðð õõ0/ðØØ!ð "qð#ñ"qà)ð"qðð"qðð "qð ð "qðð"qð ó"qóH%ðò"óð"ðò'óð'ðò%óð%ð ‡^�^ò-óð-ðò"óð"ðò"óð"ðò"óð"ðò 6óð 6ðò*óð*ð !%Ø#ðJ-ð (,Øñ J-àðJ-ððJ-ð %ð J-ð ð J-ð óJ-ôXPó&ðà,ðð(ðð(ð ð ó ÷ !rr&)#Ú __future__rÚ contextlibÚloggingrOrmriÚabcrrÚ dataclassesrÚ threadingrÚtypingrr Úweakrefr Ú_errorr ÚsysÚtypesr Ú version_inforÚtyping_extensionsÚ getLoggerrorr0r;ÚContextDecoratorr&Ú__all__r.rrÚr˜s³ðÝ"ãÛÛ Û Ûß#Ý!Ýß%Ý'åáÛÝ#à ×ј7Ò"Þå*ð ˆ'× Ñ ˜JÓ '€÷ ñð$ ÷ðó ðô,C˜_¨eôCôB!�3˜ ×3Ñ3ôB!ðLØð �r