CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
_api.cpython-310.pyc136 linesDownload Raw Back to __pycache__
1o

2��Yi�8�@s:ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	m3Z4ddlmZddl
mZddlmZmZmZddlmZdd	lmZerfddlZdd5lmZejdkr`ddlmZnddlmZe�d
�ZGdd�d�ZeGdd�d��Z Gdd�de e�Z!Gdd�de	�Z"Gdd�dej#e"d�Z$ddgZ%dS)�)�annotationsN)�ABCMeta�abstractmethod)�	dataclass)�local)�
TYPE_CHECKING�Any�cast)�WeakValueDictionary�)�Timeout)�
TracebackType)��)�Self�filelockc@s.eZdZdZddd�Zddd	�Zddd�ZdS)�AcquireReturnProxyzDA context-aware object that will release the lock file when exiting.�lock�BaseFileLock�return�NonecCs6||_dS�N�r)�selfr�r�wE:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\filelock/_api.py�__init__$s7zAcquireReturnProxy.__init__cC�|jSrr�rrrr�	__enter__'szAcquireReturnProxy.__enter__�exc_type�type[BaseException] | None�	exc_value�BaseException | None�	traceback�TracebackType | NonecCs|j��dSr)r�release�rr r"r$rrr�__exit__*szAcquireReturnProxy.__exit__N)rrrr)rr�r r!r"r#r$r%rr)�__name__�8__module__�__qualname__�__doc__rrr(rrrrr!s91011rc@sJeZdZUdZded<ded<ded<ded	<d12Zded<d
Zded<d13S)�FileLockContextzBA dataclass which holds the context for a ``BaseFileLock`` object.�str�	lock_file�float�timeout�int�mode�bool�blockingNz14int | None�lock_file_fdr�lock_counter)r*r+r,r-�__annotations__r7r8rrrrr.3s15r.c@seZdZdZdS)�ThreadLocalFileContextz8A thread local version of the ``FileLockContext`` class.N)r*r+r,r-rrrrr:Msr:cs.eZdZ			dddd�d�fdd�Z�ZS)�FileLockMeta������TF�r6�is_singletonr0�str | os.PathLike[str]r2r1r4r3�thread_localr5r6r?�kwargsrrrc	s|rS|j�t|��}|rS||��f||jf||jf||jfd�}	dd�|	��D�}16|17s0td|�Sd}|d7}|18��D]\}\}
}|d|�d|�d	|
�d19�7}q:t	|��|||||d�|�}t20�|j�j
��fdd�|��D�}t�j|fi|��}|r�||jt|�<td|�S)
N)rAr2r4r6cSs&i|]\}\}}||kr|||f�qSrr)�.0�name�passed_param�	set_paramrrr�21<dictcomp>gs2223�z)FileLockMeta.__call__.<locals>.<dictcomp>rzGSingleton lock instances cannot be initialized with differing argumentsz24Non-matching arguments: z25	z (existing lock has z but z was passed))r2r4rAr6r?csi|]\}}|�vr||�qSrr)rC�key�value�Zpresent_paramsrrrG�s)�26_instances�getr/�is_thread_localr2r4r6�itemsr	�27ValueError�inspect�	signaturer�28parameters�super�__call__)�clsr0r2r4rAr6r?rB�instanceZparams_to_checkZnon_matching_params�msg�29param_namerErF�30all_paramsZinit_params��	__class__rJrrTRs@31��32��	33zFileLockMeta.__call__�r<r=T)r0r@r2r1r4r3rAr5r6r5r?r5rBrrr)r*r+r,rT�
__classcell__rrrZrr;Qs��r;cs0eZdZUdZded<dN�fdd	�Z	34		dOdd
d�dPdd�ZdQdd�ZedQdd��Z	edRd d!��Z35edSd"d#��ZejdTd&d#��ZedQd'd(��Z
e
jdUd)d(��Z
edVd*d+��ZedWd,d-��ZedWd.d/��ZedQd0d1��ZedVd2d3��Z	4	5dXd4d4d6�dYd<d=�ZdZd[d?d@�Zd\dBdC�Zd]dJdK�ZdWdLdM�Z�ZS)^rz+Abstract base class for a file lock object.z&WeakValueDictionary[str, BaseFileLock]rKrB�dict[str, Any]rrcst�jdi|��t�|_dS)z'Setup unique state for lock subclasses.Nr)rS�__init_subclass__r36rK)rUrBrZrrr_�szBaseFileLock.__init_subclass__r<r=TFr>r0r@r2r1r4r3rAr5r6r?cCs<||_||_t�|�|||d�}|rtntdi|��|_dS)a�37        Create a new lock object.38 39        :param lock_file: path to the file40        :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.41        :param mode: file permissions for the lockfile42        :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.43        :param blocking: whether the lock should be blocking or not44        :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.45 46        )r0r2r4r6Nr)�_is_thread_local�
_is_singleton�os�fspathr:r.�_context)rr0r2r4rAr6r?rBrrrr�s�zBaseFileLock.__init__cCr)z>:return: a flag indicating if this lock is thread local or not)r`rrrrrM�szBaseFileLock.is_thread_localcCr)z;:return: a flag indicating if this lock is singleton or not)rarrrrr?�szBaseFileLock.is_singletonr/cC�|jjS)z:return: path to the lock file)rdr0rrrrr0��zBaseFileLock.lock_filecCre)za47        :return: the default timeout value, in seconds48 49        .. versionadded:: 2.0.050        )rdr2rrrrr2�szBaseFileLock.timeoutrI�float | strcCst|�|j_dS)ze51        Change the default timeout value.52 53        :param value: the new value, in seconds54 55        N)r1rdr2�rrIrrrr2�scCre)z/:return: whether the locking is blocking or not�rdr6rrrrr6�rfzBaseFileLock.blockingcCs||j_dS)zb56        Change the default blocking value.57 58        :param value: the new value as bool59 60        Nrirhrrrr6�scCre)z.:return: the file permissions for the lockfile)rdr4rrrrr4�rfzBaseFileLock.modecC�t�)zjIf the file lock could be acquired, self._context.lock_file_fd holds the file descriptor of the lock file.��NotImplementedErrorrrrr�_acquire��zBaseFileLock._acquirecCrj)z>Releases the lock and sets self._context.lock_file_fd to None.rkrrrr�_release�rnzBaseFileLock._releasecCs|jjduS)z�61 62        :return: A boolean indicating if the lock file is holding the lock currently.63 64        .. versionchanged:: 2.0.065 66            This was previously a method and is now a property.67        N)rdr7rrrr�	is_locked�s68zBaseFileLock.is_lockedcCre)zP:return: The number of times this lock has been acquired (but not yet released).)rdr8rrrrr869rfzBaseFileLock.lock_counterN皙�����?)�poll_intervallr6�float | None�
poll_intervalrr�bool | Nonerc	CsD|dur|jj}|dur|jj}|dur d}tj|tdd�|}|jjd7_t|�}|j}t	�70�}zV	|jsCt�
d||�|��|jrNt�
d||�n:|d	ur]t�
d71||�t|��d|krkt	�72�|krxnnt�
d||�t|��d
}t�
||||�t	�|�q5Wnty�td|jjd�|j_�wt|d�S)a_73        Try to acquire the file lock.74 75        :param timeout: maximum wait time for acquiring the lock, ``None`` means use the default :attr:`~timeout` is and76         if ``timeout < 0``, there is no timeout and this method will block until the lock could be acquired77        :param poll_interval: interval of trying to acquire the lock file78        :param poll_intervall: deprecated, kept for backwards compatibility, use ``poll_interval`` instead79        :param blocking: defaults to True. If False, function will return immediately if it cannot obtain a lock on the80         first attempt. Otherwise, this method will block until the timeout expires or the lock is acquired.81        :raises Timeout: if fails to acquire lock within the timeout period82        :return: a context object that will unlock the file when the context is exited83 84        .. code-block:: python85 86            # You can use this method in the context manager (recommended)87            with lock.acquire():88                pass89 90            # Or use an equivalent try-finally construct:91            lock.acquire()92            try:93                pass94            finally:95                lock.release()96 97        .. versionchanged:: 2.0.098 99            This method returns now a *proxy* object instead of *self*,100            so that it can be used in a with statement without side effects.101 102        Nz+use poll_interval instead of poll_intervall�)�103stacklevelrTz#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)rdr2r6�warnings�warn�DeprecationWarningr8�idr0�time�perf_counterrp�_LOGGER�debugrmr�sleep�
BaseException�maxr)	rr2rtrrr6rW�lock_id�
lock_filename�104start_timerrr�acquiresH( 105�106�107zBaseFileLock.acquire�forcecCsn|jr3|jjd8_|jjdks|r5t|�|j}}t�d||�|��d|j_t�d||�dSdSdS)a+108        Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0.109        Also note, that the lock file itself is not automatically deleted.110 111        :param force: If true, the lock counter is ignored and the lock is released in every case/112 113        rrz#Attempting to release lock %s on %szLock %s released on %sN)rprdr8r{r0r~rro)rr�r�r�rrrr&^s�zBaseFileLock.releasercCs|��|S)zF114        Acquire the lock.115 116        :return: the lock object117 118        )r�rrrrrqszBaseFileLock.__enter__r r!r"r#r$r%cCs|��dS)z�119        Release the lock.120 121        :param exc_type: the exception type if raised122        :param exc_value: the exception value if raised123        :param traceback: the exception traceback if raised124 125        N�r&r'rrrr({szBaseFileLock.__exit__cCs|jdd�dS)z'Called when the lock object is deleted.T)r�Nr�rrrr�__del__�szBaseFileLock.__del__)rBr^rrr\)r0r@r2r1r4r3rAr5r6r5r?r5rr)rr5)rr/)rr1)rIrgrr)rIr5rr)rr3)rr)Nrq)126r2rsrtr1rrrsr6rurr)F)r�r5rr)rrr))r*r+r,r-r9r_rrM�propertyr?r0r2�setterr6r4rrmrorpr8r�r&rr(r�r]rrrZrr�sX127��128'		��O129130 131r)�	metaclass)&�132__future__r�133contextlibrP�loggingrbr|rx�abcrr�dataclassesr�	threadingr�typingrrr	�weakrefr134�_errorr�sys�typesr
�version_inforZtyping_extensions�	getLoggerr~rr.r:r;�ContextDecoratorr�__all__rrrr�<module>s>135136=�
Aluode/PerceptionLabPortable · CoolFace