Ë
    _§1h   ã                  óô   — U d dl mZ d dlZd dlZd dlZd dlmZ d dlZddlm	Z	 ddl
mZmZ erd dlmZ erej                  dk7  sJ ‚ej                   d	k7  re‚d
Zded<    G d„ d«      Ze G d„ de	«      «       Zy)é    )ÚannotationsN)ÚTYPE_CHECKINGé   )ÚStream)ÚConflictDetectorÚfinal)ÚFinalÚwin32Úposixi   Ú	FinalTypeÚDEFAULT_RECEIVE_SIZEc                  óJ   — e Zd ZU ded<   d	d„Zed
d„«       Zdd„Zdd„Zdd„Z	y)Ú	_FdHolderÚintÚfdc                ó¶   — d| _         t        |t        «      st        d«      ‚|| _         t	        j
                  |«      | _        t	        j                  |d«       y )Néÿÿÿÿzfile descriptor must be an intF)r   Ú
isinstancer   Ú	TypeErrorÚosÚget_blockingÚ_original_is_blockingÚset_blocking©Úselfr   s     úN/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/trio/_unix_pipes.pyÚ__init__z_FdHolder.__init__0   sG   € ð ˆŒÜ˜"œcÔ"ÜÐ<Ó=Ð=ØˆŒä%'§_¡_°RÓ%8ˆÔ"Ü
�‰˜˜EÕ"ó    c                ó    — | j                   dk(  S ©Nr   )r   ©r   s    r   Úclosedz_FdHolder.closed;   s   € à�w‰w˜"‰}Ðr   c                ó®   — | j                   ry | j                  }d| _        t        j                  || j                  «       t        j
                  |«       y r    )r"   r   r   r   r   Úcloser   s     r   Ú
_raw_closez_FdHolder._raw_close?   s=   € ð �;Š;ØØ�W‰WˆØˆŒÜ
�‰˜˜D×6Ñ6Ô7Ü
�‰��r   c                ó$   — | j                  «        y ©N)r%   r!   s    r   Ú__del__z_FdHolder.__del__N   s   € Ø�‰Õr   c                ó�   — | j                   s:t        j                  j                  | j                  «       | j                  «        y y r'   )r"   ÚtrioÚlowlevelÚnotify_closingr   r%   r!   s    r   r$   z_FdHolder.closeQ   s.   € Ø�{Š{Ü�M‰M×(Ñ(¨¯©Ô1Ø�O‰OÕð r   N©r   r   ÚreturnÚNone)r.   Úbool©r.   r/   )
Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r   Úpropertyr"   r%   r(   r$   © r   r   r   r      s1   … ð$ 	ƒGó	#ð òó ðóóôr   r   c                  óJ   — e Zd ZdZd
d„Zdd„Zdd„Zddd„Zdd„Zdd„Z	dd	„Z
y)ÚFdStreama<  
    Represents a stream given the file descriptor to a pipe, TTY, etc.

    *fd* must refer to a file that is open for reading and/or writing and
    supports non-blocking I/O (pipes and TTYs will work, on-disk files probably
    not).  The returned stream takes ownership of the fd, so closing the stream
    will close the fd too.  As with `os.fdopen`, you should not directly use
    an fd after you have wrapped it in a stream using this function.

    To be used as a Trio stream, an open file must be placed in non-blocking
    mode.  Unfortunately, this impacts all I/O that goes through the
    underlying open file, including I/O that uses a different
    file descriptor than the one that was passed to Trio. If other threads
    or processes are using file descriptors that are related through `os.dup`
    or inheritance across `os.fork` to the one that Trio is using, they are
    unlikely to be prepared to have non-blocking I/O semantics suddenly
    thrust upon them.  For example, you can use
    ``FdStream(os.dup(sys.stdin.fileno()))`` to obtain a stream for reading
    from standard input, but it is only safe to do so with heavy caveats: your
    stdin must not be shared by any other processes, and you must not make any
    calls to synchronous methods of `sys.stdin` until the stream returned by
    `FdStream` is closed. See `issue #174
    <https://github.com/python-trio/trio/issues/174>`__ for a discussion of the
    challenges involved in relaxing this restriction.

    Args:
      fd (int): The fd to be wrapped.

    Returns:
      A new `FdStream` object.
    c                ód   — t        |«      | _        t        d«      | _        t        d«      | _        y )Nz*another task is using this stream for sendz-another task is using this stream for receive)r   Ú
_fd_holderr   Ú_send_conflict_detectorÚ_receive_conflict_detectorr   s     r   r   zFdStream.__init__y   s/   € Ü# B›-ˆŒÜ'7Ø8ó(
ˆÔ$ô +;Ø;ó+
ˆÕ'r   c              ƒ  ó*  K  — | j                   5  | j                  j                  rt        j                  d«      ‚t        j
                  j                  «       ƒ d {  –—†  t        |«      }t        |«      5 }d}||k  rB||d  5 }	 |t        j                  | j                  j                  |«      z  }d d d «       ||k  rŒBd d d «       d d d «       y 7 Œu# t        $ r? t        j
                  j                  | j                  j                  «      ƒ d {  –—†7   Y Œht        $ rI}|j                  t        j                   k(  rt        j                  d«      d ‚t        j"                  |‚d }~ww xY w# 1 sw Y   Œ½xY w# 1 sw Y   Œ»xY w# 1 sw Y   y xY w­w)Núfile was already closedr   )r<   r;   r"   r*   ÚClosedResourceErrorr+   Ú
checkpointÚlenÚ
memoryviewr   Úwriter   ÚBlockingIOErrorÚwait_writableÚOSErrorÚerrnoÚEBADFÚBrokenResourceError)r   ÚdataÚlengthÚviewÚsentÚ	remainingÚes          r   Úsend_allzFdStream.send_all‚   sk  è ø€ Ø×)Ñ)ñ 	Fð �‰×%Ò%Ü×.Ñ.Ð/HÓIÐIÜ—-‘-×*Ñ*Ó,×,Ð,Ü˜“YˆFä˜DÓ!ð F TØ�Ø˜V’mØ˜d˜e˜ð F¨	ð
FØ ¤B§H¡H¨T¯_©_×-?Ñ-?ÀÓ$KÑK˜D÷Fð ˜V“m÷F÷	Fð 	Fð
 -ùô  /ò RÜ"&§-¡-×"=Ñ"=¸d¿o¹o×>PÑ>PÓ"Q×QÓQÜ&ò FØ Ÿw™w¬%¯+©+Ò5Ü&*×&>Ñ&>Ø$=ó'"à'+ð!,ô '+×&>Ñ&>ÀAÐ EûðFú÷Fð Fú÷Fð Fú÷	Fð 	Füs–   ‚F�AFÁCÁFÁ7E;ÂE/Â-CÂ3E;ÃFÃ		FÃFÃ?E,	ÄDÄE,	ÄE/ÄE,	Ä#AE'	Å'E,	Å,E/Å/E8Å4E;Å;F	Æ FÆFÆFc              ƒ  óf  K  — | j                   5  | j                  j                  rt        j                  d«      ‚	 t        j
                  j                  | j                  j                  «      ƒ d {  –—†  	 d d d «       y 7 Œ# t        $ r}t        j                  |‚d }~ww xY w# 1 sw Y   y xY w­w)Nr?   )
r<   r;   r"   r*   r@   r+   rF   r   ÚBrokenPipeErrorrJ   )r   rP   s     r   Úwait_send_all_might_not_blockz&FdStream.wait_send_all_might_not_block›   s”   è ø€ Ø×)Ñ)ñ 	6Ø�‰×%Ò%Ü×.Ñ.Ð/HÓIÐIð6Ü—m‘m×1Ñ1°$·/±/×2DÑ2DÓE×EÑE÷		6ð 	6ð FùÜ"ò 6ô ×.Ñ.°AÐ5ûð6ú÷	6ð 	6üsK   ‚B1�,B%¼6BÁ2BÁ3BÁ8	B1ÂBÂ	B"ÂBÂB"Â"B%Â%B.Â*B1Nc              ƒ  óœ  K  — | j                   5  |€t        }n+t        |t        «      st	        d«      ‚|dk  rt        d«      ‚t        j                  j                  «       ƒ d {  –—†  	 	 t        j                  | j                  j                  |«      }	 |cd d d «       S 7 Œ<# t        $ r? t        j                  j                  | j                  j                  «      ƒ d {  –—†7   Y nTt        $ rI}|j                   t         j"                  k(  rt        j$                  d«      d ‚t        j&                  |‚d }~ww xY wŒÕ# 1 sw Y   y xY w­w)Nzmax_bytes must be integer >= 1r   r?   )r=   r   r   r   r   Ú
ValueErrorr*   r+   rA   r   Úreadr;   r   rE   Úwait_readablerG   rH   rI   r@   rJ   )r   Ú	max_bytesrK   Úexcs       r   Úreceive_somezFdStream.receive_some¦   s  è ø€ Ø×,Ñ,ñ 	ØÐ Ü0‘	ä! )¬SÔ1Ü#Ð$DÓEÐEØ˜q’=Ü$Ð%EÓFÐFä—-‘-×*Ñ*Ó,×,Ð,ØðÜŸ7™7 4§?¡?×#5Ñ#5°yÓA�Dð à÷3	ñ 	ð -ùô 'ò JÜŸ-™-×5Ñ5°d·o±o×6HÑ6HÓI×IÓIÜò @Ø—y‘y¤E§K¡KÒ/Ü"×6Ñ6Ø5óà#ð$ô #×6Ñ6¸CÐ?ûð@úð ÷	ð 	üsl   ‚E�AE Á%B"Á&E Á,*B$ÂE Â
EÂ"E Â$?D<Ã#C&Ã$D<Ã)E Ã+D<Ã3AD7Ä7D<Ä<E Å E	ÅEc                ó8   — | j                   j                  «        y r'   )r;   r$   r!   s    r   r$   zFdStream.closeÂ   s   € Ø�‰×ÑÕr   c              ƒ  ó|   K  — | j                  «        t        j                  j                  «       ƒ d {  –—†  y 7 Œ­wr'   )r$   r*   r+   rA   r!   s    r   ÚaclosezFdStream.acloseÅ   s%   è ø€ Ø�
‰
ŒÜ�m‰m×&Ñ&Ó(×(Ò(ús   ‚2<´:µ<c                ó.   — | j                   j                  S r'   )r;   r   r!   s    r   ÚfilenozFdStream.filenoÉ   s   € Ø�‰×!Ñ!Ð!r   r-   )rK   Úbytesr.   r/   r1   r'   )rY   z
int | Noner.   ra   )r.   r   )r2   r3   r4   Ú__doc__r   rQ   rT   r[   r$   r^   r`   r7   r   r   r9   r9   W   s,   „ ñó@
óFó2	6ôó8 ó)ô"r   r9   )Ú
__future__r   rH   r   ÚsysÚtypingr   r*   Ú_abcr   Ú_utilr   r   r	   r   ÚplatformÚnameÚImportErrorr   r5   r   r9   r7   r   r   ú<module>rk      s�   ðÞ "ã Û 	Û 
Ý  ã å ß *áÝ)á˜CŸL™L¨GÒ3Ð 3Ð3à‡7�7ˆgÒð Ðð #(Ð �iÓ '÷8ñ 8ðv ôr"ˆvó r"ó ñr"r   