← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/filelock/__pycache__/_descriptor.cpython-312.pyc

47 lines

�

c�bj����dZddlmZddlZddlZddlmZddlmZejdk(r	ddl
mZmZnddl
mZmZd	d
d�dd�Zdd
�ZddgZy)znA minimal native lock over a caller-owned file descriptor, contending with :class:`FileLock` on the same file.�)�annotationsN)�isfinite)�Final�win32�)�_lock_fd_nonblocking�
_unlock_fdTg�������?)�blocking�
poll_intervalc��|st|�St|�r|dkrd|��}t|��t|�s!tj|�t|�s�!y)a
    Take the native OS lock on *fd*, a file descriptor the caller opened and owns.

    This is the same one-byte exclusive lock :class:`FileLock` uses, so a descriptor lock and a path lock on the same
    file contend with each other. Unlike :class:`FileLock` it adds no path handling: it never opens, truncates, closes,
    unlinks, chmods, canonicalizes, or falls back. The caller owns *fd* before, during, and after the call, and must
    close it. On Windows *fd* must be a synchronous descriptor (its handle not opened with ``FILE_FLAG_OVERLAPPED``).

    For timeout, reentrancy, singleton, lifetime, or stale-break behavior, use :class:`FileLock`. There is no async
    wrapper. Run this in an executor, or drive ``blocking=False`` from your own polling loop.

    :param fd: an open file descriptor the caller owns.
    :param blocking: when ``True`` (default), retry the nonblocking attempt every *poll_interval* seconds until it
        succeeds; when ``False``, make one attempt.
    :param poll_interval: finite, positive seconds between attempts while blocking; ignored when *blocking* is
        ``False``.

    :returns: ``True`` once the lock is held, or ``False`` on contention when ``blocking`` is ``False``.

    :raises OSError: for a permanent native failure, such as an invalid descriptor, or with ``errno.ENOSYS`` when the
        Python build lacks the native locking primitive. The descriptor is left open.
    :raises ValueError: if a blocking call receives a non-finite or non-positive *poll_interval*.

    .. versionadded:: 3.30.0

    rz5poll_interval must be finite and greater than 0, got T)rr�
ValueError�time�sleep)�fdr
r�msgs    �k/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/filelock/_descriptor.py�lock_descriptorrsZ��6�#�B�'�'��M�"�m�q�&8�Q�R_�Q`�a����o��"�2�&��
�
�=�!�#�2�&��c��t|�y)a�
    Release the native OS lock on *fd* without touching the descriptor.

    :param fd: the descriptor a prior :func:`lock_descriptor` locked; the caller still owns and must close it.

    :raises OSError: if the native unlock fails, including ``errno.ENOSYS`` when the Python build lacks the native
        locking primitive; the caller may retry on the same descriptor.

    .. versionadded:: 3.30.0

    N)r	)rs r�unlock_descriptorr5s���r�Nrrr)r�intr
�boolr�float�returnr)rrr�None)�__doc__�
__future__r�sysr�mathr�typingr�platform�_windowsrr	�_unixrr�__all__�rr�<module>r&sM��t�"�
�����<�<�7��:�:�7�26�d�"�J� ���r