Ë
    ­Ó^j¥  ã                  óœ   — d Z ddlmZ ddlZddlZddlmZ ddlmZ ej                  dk(  r	ddl
mZmZ nddlmZmZ d	d
dœdd„Zdd„ZddgZy)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               ó¶   — |st        | «      S t        |«      r|dk  rd|› �}t        |«      ‚t        | «      s!t        j                  |«       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

    r   z5poll_interval must be finite and greater than 0, got T)r   r   Ú
ValueErrorÚtimeÚsleep)Úfdr
   r   Úmsgs       ú_/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/filelock/_descriptor.pyÚlock_descriptorr      sZ   € ñ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	   )r   s    r   Úunlock_descriptorr   5   s   € ô ˆr…Nr   r   r   )r   Úintr
   Úboolr   ÚfloatÚreturnr   )r   r   r   ÚNone)Ú__doc__Ú
__future__r   Úsysr   Úmathr   Útypingr   ÚplatformÚ_windowsr   r	   Ú_unixr   r   Ú__all__© r   r   ú<module>r&      sM   ðÙ tå "ã 
Û Ý Ý à‡<�<�7Òß:Ð:ç7ð 26Èdõ "óJð  Øð�r   