+
    lHàj	  ã                   óR   € R t ^ RIt^ RIt^ RIt^ RIt^ RIt ! R R4      tR R ltR# )aÉ  POSIX fd-readiness helper shared by the stdout drains and the PTY bridge.

``select.select()`` raises ``ValueError: filedescriptor out of range in select()``
once an fd reaches FD_SETSIZE (1024). A long-lived gateway/desktop process holds
that many open fds, and every drain swallowed that ValueError as "fd already
closed", silently discarding output (issue #94928).

``selectors.DefaultSelector`` (epoll on Linux, kqueue on macOS) has no FD_SETSIZE
ceiling. ``poll()`` is not the default: macOS ``poll()`` does not support device
fds and reports a PTY master as POLLNVAL, i.e. "ready" at once, so a PTY read loop
would spin a core. It stays the fallback because, unlike epoll/kqueue, it needs no
fd of its own.
Nc                   óZ   a € ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltRtV t	R	# )
ÚFdWaiterz�Readability wait on one fd. Owns a selector (epoll/kqueue are fds themselves):
create it once per reader lifetime and ``close()`` it when the reader is done.c                ó    <€ V ^8„  d   QhRS[ /# ©é   Úfd©Úint)ÚformatÚ__classdict__s   "€Ú?/home/ubuntu/.hermes/hermes-agent/tools/environments/fd_wait.pyÚ__annotate__ÚFdWaiter.__annotate__   s   ø€ ÷ ñ ™3ñ ó    c                óÈ   € V! 4       V n          V P                   P                  V\        P                  4       R #   \         d    T P                   P                  4        h i ; i©N)Ú	_selectorÚregisterÚ	selectorsÚ
EVENT_READÚBaseExceptionÚclose)Úselfr   Úselector_clss   &&&r   Ú__init__ÚFdWaiter.__init__   sL   € Ù%›ˆŒð	Ø�N‰N×#Ñ# B¬	×(<Ñ(<Ö=øÜô 	Ø�N‰N× Ñ Ô"Øð	ús	   Ž*: º'A!c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r   Ú	timeout_sÚreturn)ÚfloatÚbool)r
   r   s   "€r   r   r   "   s   ø€ ÷ >ñ >™eð >©ñ >r   c                ó^   € \        V P                  P                  \        V^ 4      4      4      # )zbTrue as soon as the fd is readable (EOF and hangup included), False when
*timeout_s* elapses idle.)r    r   ÚselectÚmax)r   r   s   &&r   ÚwaitÚFdWaiter.wait"   s%   € ô �D—N‘N×)Ñ)¬#¨i¸Ó*;Ó<Ó=Ð=r   c                ó   <€ V ^8„  d   QhRR/# )r   r   N© )r
   r   s   "€r   r   r   '   s   ø€ ÷ ñ �tñ r   c                ó:   € V P                   P                  4        R # r   )r   r   )r   s   &r   r   ÚFdWaiter.close'   s   € Ø�‰×ÑÖr   )r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r$   r   Ú__static_attributes__Ú__classdictcell__)r   s   @r   r   r      s)   ø‡ € ñV÷ð ÷>ð >÷
ö r   r   c                ó$   € V ^8„  d   QhR\         /# r   r   )r
   s   "r   r   r   +   s   € ÷ 0ñ 0”sñ 0r   c                ó   €  \        V \        P                  4      #   \         d     R# \         d€   pTP
                  \
        P                  8X  d    Rp?R# \        P                  R8X  d<   \        P                  ! \        P                  ! T 4      P                  4      '       d   h  Rp?MRp?ii ; i\        T \        P                  4      # )z–Return an :class:`FdWaiter` for *fd*, or None only when *fd* is closed/invalid
and there is nothing to drain. Raises OSError when no safe wait exists.NÚdarwin)r   r   ÚDefaultSelectorÚ
ValueErrorÚOSErrorÚerrnoÚEBADFÚsysÚplatformÚstatÚS_ISCHRÚosÚfstatÚst_modeÚPollSelector)r   Úexcs   & r   Úopen_fd_waiterrB   +   s‹   € ðÜ˜œI×5Ñ5Ó6Ð6øÜô ÚÜô Ø�9‰9œŸ™Ô#Ýô �<‰<˜8Ô#¬¯ª´R·X²X¸b³\×5IÑ5I×(JÒ(JØÿøðúô �Bœ	×.Ñ.Ó/Ð/s+   ‚ œB3ªB3³B3´B.ÁAB.Â(B.Â.B3)r.   r7   r=   r   r;   r9   r   rB   r'   r   r   Ú<module>rC      s*   ðñó Û 	Û Û Û 
÷ñ ÷*0r   