Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
_api.cpython-313.pyc228 linesDownload Raw Back to __pycache__
1�

2�jcS���%SSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK3JrJr SSK
Jr SSKJr SSKJrJrJr SSKJr SS	KJr S4rS\S'\(a5SS
KJr SSKJr SSKJ r  SSK!J"r" \RFS:�aSSKJ$r$ OSSK%J$r$ \RL"S5r'\RPS:Xa\RRRTO\RRRVr,"SS\5r-\-"5r."SS5r/\"SS55r0"SS\0\5r1\"SSS9r2"S S!\5r3"S"S\Rh\3S#9r5/S$Qr6g)%�)�annotationsN)�ABCMeta�abstractmethod)�	dataclass)�local)�
TYPE_CHECKING�Any�TypeVar)�WeakValueDictionary�)�Timeout������int�_UNSET_FILE_MODE)�Callable)�
TracebackType)�
ReadWriteLock)�SoftReadWriteLock)��)�Self�filelock�win32c�,^�\rSrSrSU4SjjrSrU=r$)�_ThreadLocalRegistry�,c�0>�[TU]5 0Ulg�N)�super�__init__�held)�self�	__class__s ��SD:\code\apps\devtools\python\user_packages\Python313\site-packages\filelock/_api.pyr �_ThreadLocalRegistry.__init__-s���
����$&��	�)r!��return�None)�__name__�5__module__�__qualname__�__firstlineno__r �__static_attributes__�
__classcell__�r#s@r$rr,s
���'�'r&rc�F�\rSrSrSrSSjrS	SjrS6SjrSrg)�AcquireReturnProxy�8zDA context-aware object that will release the lock file when exiting.c��Xlgr��lock)r"r6s  r$r �AcquireReturnProxy.__init__;s��FJ�	r&c��UR$rr5�r"s r$�	__enter__�AcquireReturnProxy.__enter__>s���y�y�r&c�8�URR5 gr)r6�release�r"�exc_type�	exc_value�	tracebacks    r$�__exit__�AcquireReturnProxy.__exit__As��	
�	�	���r&r5N)r6�0BaseFileLock | ReadWriteLock | SoftReadWriteLockr(r))r(rD�r?ztype[BaseException] | Noner@zBaseException | NonerAzTracebackType | Noner(r))	r*r+r,r-�__doc__r r:rBr.�r&r$r2r28s;��N�K���,��(��(�	�78�r&r2c�v�\rSrSr%SrS\S'S\S'S\S'S	\S9'S\S'SrS
\S'SrS\S'SrS\S'Sr	g)�FileLockContext�JzBA dataclass which holds the context for a ``BaseFileLock`` object.�str�	lock_file�float�timeoutr�mode�bool�blocking�
poll_intervalN�float | None�lifetimez10int | None�lock_file_fdr�lock_counterrG)11r*r+r,r-rF�__annotations__rTrUrVr.rGr&r$rIrIJsM��L��N��N��I��N���"�H�l�!� $�L�*�#��L�#�r&rIc��\rSrSrSrSrg)�ThreadLocalFileContext�jz8A thread local version of the ``FileLockContext`` class.rGN)r*r+r,r-rFr.rGr&r$rYrYjs��Br&rY�_T�BaseFileLock)�boundc�z^�\rSrSr%S\S'S\S4SSSSS	.SU4S12jjjjrSrU=r$)
�FileLockMeta�q�&WeakValueDictionary[str, BaseFileLock]�13_instancesrTF皙�����?N�rQ�is_singletonrRrTc	�N>�U(a�URR[U55n14U15(a�XJR54X*R4X:R16R4XZR4XzR4X�R4S.nUR5VV
Vs0sHunup�X�:wdMX�U4_M nn
nnU(dU17$SnUS-
nUR5Hunup�USUSUSU
S3-
nM [U5eUUUUUUUS.U	En[R"UR5RnUR5VVs0sHunnUU;dMUU_M nnn[ TU]D"U40UD6n18U(aX�R[U5'U19$s snn
nfs snnf)	N)�thread_localrNrOrQrRrTzGSingleton lock instances cannot be initialized with differing argumentsz20Non-matching arguments: z21	z (existing lock has z but z was passed))rNrOrgrQrerRrT)rb�getrK�is_thread_localrN�_contextrOrQrRrT�items�22ValueError�inspect�	signaturer �23parametersr�__call__)�clsrLrNrOrgrQrerRrT�kwargs�instance�params_to_check�name�passed_param�	set_param�non_matching_params�msg�24param_name�25all_params�present_params�key�value�init_paramsr#s                       �r$rp�FileLockMeta.__call__ts������~�~�)�)�#�i�.�9�H��%1�3K�3K�3M�$N� '�)9�)9�:�!�#4�#4�#9�#9�:�!)�+<�+<� =�&3�5K�5K�%L�!)�+<�+<� =�
#��<K�;P�;P�;R�'�;R�7��7�|�#�0�4�D��3�3�;R�$�'�26+�#�O�`���3�3��=P�=V�=V�=X�9�J� 9���T�*��-A�)��E�R^�Q_�_k�l�l�C�>Y� ��o�%���(� �(�*� �	27��	28�29�!�*�*�3�<�<�8�C�C��4>�4D�4D�4F�`�4F�j�c�5�#�Q_�J_�z�s�E�z�4F��`��7�#�I�=��=���-5�N�N�3�y�>�*����M'��>as�!F�3F�
F!�F!rG)rqztype[_T]rL�str | os.PathLike[str]rNrMrOrrgrPrQrPrerPrRrMrTrSrrr	r(r[)	r*r+r,r-rWrrpr.r/r0s@r$r_r_qs����6�6�30�$�!�?��"�#�!%�?�
�?�)�?��?��	?�31�?��?��?��?��?��?�32�?�?r&r_c��^�\rSrSr%SrS\S'S(U4SjjrS\S4SSS	S33S.S)SjjjrS*S
jr	\34S*Sj5r\35S+Sj5r\36S,Sj5r
\
RS-Sj5r
\37S*Sj5r\RS.Sj5r\38S,Sj5r\RS/Sj5r\39S0Sj5r\RS1Sj5r\40S2Sj5r\41S*Sj5rS2SjrS3Sjr\S3Sj5r\S3Sj5r\42S*Sj5r\43S2Sj5r\S4S j5rS5S44S45S46S!.S6S"jjjrS7S8S#jjrS9S$jrS:S%jr S3S&jr!S'r"U=r#$);r\�aH47Abstract base class for a file lock object.48 49Provides a reentrant, cross-process exclusive lock backed by OS-level primitives. Subclasses implement the actual50locking mechanism (:class:`UnixFileLock <filelock.UnixFileLock>`, :class:`WindowsFileLock51<filelock.WindowsFileLock>`, :class:`SoftFileLock <filelock.SoftFileLock>`).52 53rarbc�D>�[TU]"S0UD6 [5Ulg)z'Setup unique state for lock subclasses.NrG)r�__init_subclass__rrb)rqrrr#s  �r$r��BaseFileLock.__init_subclass__�s���
��!�+�F�+�,�.��r&rTFrcNrdc��X@lX`l[R"U5UUUUUS.n	U(a[O[54"S0U	D6Ulg)a�55Create a new lock object.56 57:param lock_file: path to the file58:param timeout: default timeout when acquiring the lock, in seconds. It will be used as fallback value in the59    acquire method, if no timeout value (``None``) is given. If you want to disable the timeout, set it to a60    negative value. A timeout of 0 means that there is exactly one attempt to acquire the file lock.61:param mode: file permissions for the lockfile. When not specified, the OS controls permissions via umask and62    default ACLs, preserving POSIX default ACL inheritance in shared directories.63:param thread_local: Whether this object's internal context should be thread local or not. If this is set to64    ``False`` then the lock will be reentrant across threads.65:param blocking: whether the lock should be blocking or not66:param is_singleton: If this is set to ``True`` then only one instance of this class will be created per lock67    file. This is useful if you want to use the lock object for reentrant locking without needing to pass the68    same object around.69:param poll_interval: default interval for polling the lock file, in seconds. It will be used as fallback value70    in the acquire method, if no poll_interval value (``None``) is given.71:param lifetime: maximum time in seconds a lock can be held before it is considered expired. When set, a waiting72    process will break a lock whose file modification time is older than ``lifetime`` seconds. ``None`` (the73    default) means locks never expire.74 75)rLrNrOrQrRrTNrG)�_is_thread_local�
_is_singleton�os�fspathrYrIrj)76r"rLrNrOrgrQrerRrTrrs77          r$r �BaseFileLock.__init__�sR��D!-��)��78���9�-��� �*� �
"79��EQ�*@�Ve�*e�)p�io�)p��
r&c��UR$)z?:returns: a flag indicating if this lock is thread local or not)r�r9s r$ri�BaseFileLock.is_thread_local�s���$�$�$r&c��UR$)zY80:returns: a flag indicating if this lock is singleton or not81 82.. versionadded:: 3.13.083 84)r�r9s r$re�BaseFileLock.is_singleton�s���!�!�!r&c�.�URR$)z:returns: path to the lock file)rjrLr9s r$rL�BaseFileLock.lock_files���}�}�&�&�&r&c�.�URR$)zK85:returns: the default timeout value, in seconds86 87.. versionadded:: 2.0.088 89)rjrNr9s r$rN�BaseFileLock.timeouts���}�}�$�$�$r&c�8�[U5URlg)zM90Change the default timeout value.91 92:param value: the new value, in seconds93 94N)rMrjrN�r"r~s  r$rNr�s��!&�e���
�
�r&c�.�URR$)zM95:returns: whether the locking is blocking or not96 97.. versionadded:: 3.14.098 99�rjrQr9s r$rQ�BaseFileLock.blocking����}�}�%�%�%r&c�$�XRlg)zJ100Change the default blocking value.101 102:param value: the new value as bool103 104Nr�r�s  r$rQr�)���"'�
�
�r&c�.�URR$)zO105:returns: the default polling interval, in seconds106 107.. versionadded:: 3.24.0108 109�rjrRr9s r$rR�BaseFileLock.poll_interval3s���}�}�*�*�*r&c�$�XRlg)zP110Change the default polling interval.111 112:param value: the new value, in seconds113 114Nr�r�s  r$rRr�=s��',�
�
�#r&c�.�URR$)zj115:returns: the lock lifetime in seconds, or ``None`` if the lock never expires116 117.. versionadded:: 3.24.0118 119�rjrTr9s r$rT�BaseFileLock.lifetimeGr�r&c�$�XRlg)zg120Change the lock lifetime.121 122:param value: the new value in seconds, or ``None`` to disable expiration123 124Nr�r�s  r$rTr�Qr�r&c�n�URR[:XaS$URR$)z/:returns: the file permissions for the lockfilei��rjrOrr9s r$rO�BaseFileLock.mode[s+���
�
�*�*�.>�>�u�V�D�M�M�DV�DV�Vr&c�<�URR[:g$)z::returns: whether the file permissions were explicitly setr�r9s r$�has_explicit_mode�BaseFileLock.has_explicit_mode`s���}�}�!�!�%5�5�5r&c�n�URR[:XaS$URR$)ue:returns: the mode for os.open() — 0o666 when unset (let umask/ACLs decide), else the explicit modei�r�r9s r$�125_open_mode�BaseFileLock._open_modees)���
�
�*�*�.>�>�u�V�D�M�M�DV�DV�Vr&c�F�URR=ncg[R"[5 [126R127"5[R"UR5R5R-128U:a129SSS5 gURS[R"53n[R"UR5RU5 [R"U5R5 SSS5 g!,(df   g=f)zVRemove the lock file if its modification time exceeds the configured :attr:`lifetime`.Nz.break.)rjrT�130contextlib�suppress�OSError�time�pathlib�PathrL�stat�st_mtimer��getpid�rename�unlink)r"rT�131break_paths   r$�_try_break_expired_lock�$BaseFileLock._try_break_expired_lockis����
�
�.�.�.�H�7��
�
 �
 ��
)��y�y�{�W�\�\�$�.�.�9�>�>�@�I�I�I�H�T��*�
)�!�N�N�+�7�2�9�9�;�-�@�J��L�L����(�/�/�132�;��L�L��$�+�+�-�*�
)�
)�s�AD�A7D�133D c��[e)zjIf the file lock could be acquired, self._context.lock_file_fd holds the file descriptor of the lock file.��NotImplementedErrorr9s r$�_acquire�BaseFileLock._acquiret�134��"�!r&c��[e)z>Releases the lock and sets self._context.lock_file_fd to None.r�r9s r$�_release�BaseFileLock._releaseyr�r&c�2�URRSL$)z�135:returns: A boolean indicating if the lock file is holding the lock currently.136 137.. versionchanged:: 2.0.0138 139    This was previously a method and is now a property.140 141N)rjrUr9s r$�	is_locked�BaseFileLock.is_locked~s���}�}�)�)��5�5r&c�.�URR$)zQ:returns: The number of times this lock has been acquired (but not yet released).)rjrVr9s r$rV�BaseFileLock.lock_counter�s���}�}�)�)�)r&c��USLa[RSX5 gUb#U"5(a[RSX5 gSUs=::a[R"5U-142:aO g[RSX5 gg)NFz+Failed to immediately acquire lock %s on %sTz(Cancellation requested for lock %s on %srz"Timeout on acquiring lock %s on %s)�_LOGGER�debugr��perf_counter)�lock_id�
lock_filenamerQ�cancel_checkrN�143start_times      r$�_check_give_up�BaseFileLock._check_give_up�ss���u���M�M�G��`���#�����M�M�D�g�]����:�$�+�+�-�144�:�:��
�M�M�>��W��r&)�poll_intervallrQr�c	��UcURRnUcURRnUbSn[R"U[145SS9 UnUbUOURRnUR=RS-
sl[U5nURn[U5n	URRS:H=(a& UR(+=(a US:=(a Un146U147(aW[RRU	5=nb5X�:wa0UR=RS-slSUS3n[U5e[ R""5nUR(d6UR%5 [&R)S	Xx5 UR+5 UR(a[&R)S148Xx5 OTUR-UUUUUUS9(a[/U5eSn[&R)XgX�5 [ R0"U5 M�URRS:XaU[RU	'[9US
9$![2an [5SURRS-1495URlURRS:Xa [RR7U	S5 ef=f)a�150Try to acquire the file lock.151 152:param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and153    if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired154:param poll_interval: interval of trying to acquire the lock file, ``None`` means use the default155    :attr:`~poll_interval`156:param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead157:param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the158    first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.159:param cancel_check: a callable returning ``True`` when the acquisition should be canceled. Checked on each poll160    iteration. When triggered, raises :class:`~Timeout` just like an expired timeout.161 162:returns: a context object that will unlock the file when the context is exited163 164:raises Timeout: if fails to acquire lock within the timeout period165 166.. code-block:: python167 168    # You can use this method in the context manager (recommended)169    with lock.acquire():170        pass171 172    # Or use an equivalent try-finally construct:173    lock.acquire()174    try:175        pass176    finally:177        lock.release()178 179.. versionchanged:: 2.0.0180 181    This method returns now a *proxy* object instead of *self*, so that it can be used in a with statement182    without side effects.183 184Nz+use poll_interval instead of poll_intervall�)�185stacklevelrrzDeadlock: lock 'z�' is already held by a different FileLock instance in this thread. Use is_singleton=True to enable reentrant locking across instances.z#Attempting to acquire lock %s on %szLock %s acquired on %s)rQr�rNr�z2Lock %s not acquired on %s, waiting %s seconds ...r5)rjrNrQ�warnings�warn�DeprecationWarningrRrV�idrL�186_canonicalr��	_registryr!rh�RuntimeErrorr�r�r�r�r�r�r�r
�sleep�
BaseException�max�popr2)
r"rNrRr�rQr�ryr�r��	canonical�would_block�existingr�s
             r$�acquire�BaseFileLock.acquire�s]��\�?��m�m�+�+�G����}�}�-�-�H��%�?�C��M�M�#�1�a�@�*�M�)6�)B�
��
�
�Hc�Hc�
�	
�
�
�"�"�a�'�"��T�(�����
��}�-�	��m�m�0�0�A�5�i�d�n�n�:L�i�QX�[\�Q\�i�ai���	���(:�(:�9�(E�E�H�R�W_�Wj��M�M�&�&�!�+�&�"�=�/�2=�>�
�187�s�#�#��&�&�(�188�	���~�~��0�0�2��M�M�"G��`��M�M�O��>�>��M�M�":�G�S���&�&��!�%�!-�#�)�
'��"�-�0�0�J���
�
�c�M�I��189�190�=�)�'�2�=�=�%�%��*�(/�I�N�N�9�%�!�t�,�,���	�),�Q��
�
�0J�0J�Q�0N�)O�D�M�M�&��}�}�)�)�Q�.����"�"�9�d�3��		�s�*A/I$�AI$�$A8Kc���UR(a�UR=RS-slURRS:XdU(a�[U5URp2[191R
SX#5 UR5 SURl[RR[U5S5 [192R
SX#5 ggg)z�193Release the file lock. The lock is only completely released when the lock counter reaches 0. The lock file194itself is not automatically deleted.195 196:param force: If true, the lock counter is ignored and the lock is released in every case.197 198rrz#Attempting to release lock %s on %sNzLock %s released on %s)r�rjrVr�rLr�r�r�r�r!r�r�)r"�forcer�r�s    r$r=�BaseFileLock.releases����>�>��M�M�&�&�!�+�&��}�}�)�)�Q�.�%�)+�D��4�>�>���
�
�C�W�\��
�
��-.��
�
�*����"�"�:�m�#<�d�C��
�
�6��O�38�r&c�&�UR5 U$)z/199Acquire the lock.200 201:returns: the lock object202 203)r�r9s r$r:�BaseFileLock.__enter__#s��	
�����r&c�$�UR5 g)z�204Release the lock.205 206:param exc_type: the exception type if raised207:param exc_value: the exception value if raised208:param traceback: the exception traceback if raised209 210N�r=r>s    r$rB�BaseFileLock.__exit__-s
��	
���r&c�"�URSS9 g)z'Called when the lock object is deleted.T)r�Nr�r9s r$�__del__�BaseFileLock.__del__=s�����4�� r&)rjr�r�)rrzdict[str, Any]r(r))rLr�rNrMrOrrgrPrQrPrerPrRrMrTrSr(r))r(rP)r(rK)r(rM)r~zfloat | strr(r))r~rPr(r))r~rMr(r))r(rS)r~rSr(r))r(rr')r�rr�rKrQrPr��Callable[[], bool] | NonerNrMr�rMr(rP)NN)rNrSrRrSr�rSrQzbool | Noner�r�r(r2)F)r�rPr(r))r(rrE)$r*r+r,r-rFrWr�rr ri�propertyrerLrN�setterrQrRrTrOr�r�r�rr�r�r�rV�staticmethodr�r�r=r:rBr�r.r/r0s@r$r\r\�s�����7�6�/��$�!�/q��"�#�!%�/q�)�/q��/q��	/q�211�/q��/q��/q��/q��/q�212�/q�b%��"��"��'��'��%��%�
�^�^�-��-��&��&��_�_�'��'��+��+����,��,��&��&��_�_�'��'��W��W��6��6�W�	.��"��"��"��"��	6��	6��*��*��������	�2130���
���214����,!%�&*�i-�215(,� $�26�i-��i-�$�i-�216%�i-��
i-�0�i-�217�i-�VP�(��,��(��(�	�218219�� !�!r&)�	metaclass)rr2r\)7�220__future__rr�rm�loggingr�r��sysr�r��abcrr�dataclassesr�	threadingr�typingrr	r221�weakrefr�_errorr
rrW�collections.abcr�typesr�_read_writer�_soft_rwr�version_infor�typing_extensions�	getLoggerr��platform�path�abspath�realpathr�rr�r2rIrYr[r_�ContextDecoratorr\�__all__rGr&r$�<module>rs!��"����	��222���'�!��.�.�'��223��#���(�#�*�+�224���7�"��*��225�226�J�227'��!$���� 7�R�W�W�_�_�R�W�W�=M�=M�228�'�5�'�
!�"�	���$�����>C�_�e�C�
�T��(��B�7�B�JI!�:�.�.�,�I!�X�r&
codekingpro/portable-devtools · Team Ai