• File: _api.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib/python3.7/site-packages/filelock/__pycache__/_api.cpython-37.pyc
  • Date Modified: 05/31/2024 2:09 PM
  • File size: 7.31 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

a @sddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZddlmZed	ZGd
ddZGdd
d
eZd
dgZdS))annotationsN)ABCabstractmethod)Lock)
TracebackType)Any)TimeoutZfilelockc@sBeZdZdZdddddZdddd	Zd
dddd
ddZdS)AcquireReturnProxyzDA context aware object that will release the lock file when exiting.BaseFileLockNone)lockreturncCs
||_dS)N)r
)selfr
r>/opt/alt/python37/lib/python3.7/site-packages/filelock/_api.py__init__szAcquireReturnProxy.__init__)rcCs|jS)N)r
)rrrr	__enter__szAcquireReturnProxy.__enter__ztype[BaseException] | NonezBaseException | NonezTracebackType | None)exc_type	exc_value	tracebackrcCs|jdS)N)r
release)rrrrrrr__exit__szAcquireReturnProxy.__exit__N)__name__
__module____qualname____doc__rrrrrrrr
sr
c@seZdZdZd/ddddddZed	d
ddZedd
d
dZejdddddZe	dd
ddZ
e	dd
ddZedd
ddZd0ddddddddd Z
d1ddd"d#d$Zdd
d%d&Zd'd(d)dd*d+d,Zdd
d-d.ZdS)2rz+Abstract base class for a file lock object.zstr | os.PathLike[Any]floatr)	lock_filetimeoutrcCs*t||_d|_||_t|_d|_dS)a
        Create a new lock object.

        :param lock_file: path to the file
        :param timeout: default timeout when acquiring the lock. 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.
        Nr)osfspath
_lock_file
_lock_file_fdr r_thread_lock
_lock_counter)rrr rrrr)s

zBaseFileLock.__init__str)rcCs|jS)z:return: path to the lock file)r#)rrrrrCszBaseFileLock.lock_filecCs|jS)zU
        :return: the default timeout value

        .. versionadded:: 2.0.0
        )_timeout)rrrrr HszBaseFileLock.timeoutzfloat | str)valuercCst||_dS)zX
        Change the default timeout value.

        :param value: the new value
        N)rr()rr)rrrr QscCstdS)zbIf the file lock could be acquired, self._lock_file_fd holds the file descriptor of the lock file.N)NotImplementedError)rrrr_acquireZszBaseFileLock._acquirecCstdS)z6Releases the lock and sets self._lock_file_fd to None.N)r*)rrrr_release_szBaseFileLock._releaseboolcCs
|jdk	S)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)r$)rrrr	is_lockedds
zBaseFileLock.is_lockedNēš™?)poll_intervallzfloat | Noner
)r 
poll_intervalr0rcCsT|dkr|j}|dk	r.d}tj|tdd|}|j|jd7_WdQRXt|}|j}t}yx|j"|j	st
d|||WdQRX|j	rt
d||Pqhd|krt|krnnt
d	||t
|jqhd
}t
||||t|qhWWn<tk
rH|jtd|jd|_WdQRXYnXt|dS)az
        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
        :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.

        Nz+use poll_interval instead of poll_intervall)
stacklevelrz#Attempting to acquire lock %s on %szLock %s acquired on %srz"Timeout on acquiring lock %s on %sz2Lock %s not acquired on %s, waiting %s seconds ...)r
)r warningswarnDeprecationWarningr%r&idr#timer._LOGGERdebugr+r	Zsleep
BaseExceptionmaxr
)rr r1r0msglock_id
lock_filenameZ
start_timerrracquireps>% zBaseFileLock.acquireF)forcerc	Csr|jb|jrd|jd8_|jdks*|rdt||j}}td|||d|_td||WdQRXdS)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/
        rrz#Attempting to release lock %s on %szLock %s released on %sN)r%r.r&r7r#r9r:r,)rrAr>r?rrrrszBaseFileLock.releasecCs||S)zE
        Acquire the lock.

        :return: the lock object
        )r@)rrrrrszBaseFileLock.__enter__ztype[BaseException] | NonezBaseException | NonezTracebackType | None)rrrrcCs|dS)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)rrrrrrrrs
zBaseFileLock.__exit__cCs|jdddS)z'Called when the lock object is deleted.T)rAN)r)rrrr__del__szBaseFileLock.__del__)r)Nr/)F)rrrrrpropertyrr setterrr+r,r.r@rrrrBrrrrr&s		F	r)Z
__future__rZloggingr!r8r4abcrrZ	threadingrtypesrtypingrZ_errorr	Z	getLoggerr9r
r__all__rrrr<module>s
H