§
    eÉÝjÍ  ã                  óª   — d Z ddlmZ g d¢ZddlZddlZddlm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dS )znA minimal native lock over a caller-owned file descriptor, contending with :class:`FileLock` on the same file.é    )Úannotations)zfilelock._unixÚ	threadingÚtypingN)ÚTIMEOUT_MAX)ÚFinal)Ú_secondsÚwin32)Ú_lock_fd_nonblockingÚ
_unlock_fdTgš™™™™™©?)ÚblockingÚpoll_intervalÚfdÚintr   Úboolr   ÚfloatÚreturnc               ó  — |st          | ¦  «        S dt          d|¦  «        x}cxk     rt          k    sn dt          › d|› �}t          |¦  «        ‚t          | ¦  «        s#t	          j        |¦  «         t          | ¦  «        ¯#dS )aI  
    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: positive seconds between attempts while blocking, at most :data:`threading.TIMEOUT_MAX`;
        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 *poll_interval* outside that range, including ``nan``.

    .. versionadded:: 3.30.0

    r   r   z1poll_interval must be greater than 0 and at most z, got T)r
   r   r   Ú
ValueErrorÚtimeÚsleep)r   r   r   Úmsgs       ú\/home/spazio/cosmos_universe_media/venv/lib/python3.11/site-packages/filelock/_descriptor.pyÚlock_descriptorr      s¡   € ð6 ð (Ý# BÑ'Ô'Ð'à¥¨/¸=Ñ!IÔ!IÐI�ÐYÐYÒYÐYÍkÒYÐYÐYÐYØpÍkÐpÐpÐanÐpÐpˆÝ˜‰oŒoÐÝ" 2Ñ&Ô&ð "ÝŒ
�=Ñ!Ô!Ð!õ # 2Ñ&Ô&ð "àˆ4ó    ÚNonec                ó$   — t          | ¦  «         dS )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   :   s   € õ ˆr�N„N€N€N€Nr   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )Ú__doc__Ú
__future__r   Ú__lazy_modules__Úsysr   r   r   r   r   Úfilelock._apir   ÚplatformÚfilelock._windowsr
   r   Úfilelock._unixr   r   Ú__all__© r   r   ú<module>r(      sþ   ðØ tÐ tà "Ð "Ð "Ð "Ð "Ð "à<Ð<Ð<Ð à 
€
€
€
Ø €€€Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð à "Ð "Ð "Ð "Ð "Ð "à„<�7ÒÐØBÐBÐBÐBÐBÐBÐBÐBÐBà?Ð?Ð?Ð?Ð?Ð?Ð?Ð?ð 26Èdð #ð #ð #ð #ð #ð #ðLð ð ð ð  Øð€€€r   