
    vKg                        % S SK Jr  S SKrS SKrS SKrS SKJr  S SKrSSKJ	r	  SSK
JrJr  \(       a  S SKJr  \(       a  \R                  S:w  d   e\R                   S	:w  a  \eS
rS\S'    " S S5      r\ " S S\	5      5       rg)    )annotationsN)TYPE_CHECKING   )Stream)ConflictDetectorfinal)Finalwin32posixi   	FinalTypeDEFAULT_RECEIVE_SIZEc                  \    \ rS rSr% S\S'   SS jr\SS j5       rSS jrSS jr	SS jr
S	rg
)	_FdHolder   intfdc                    SU l         [        U[        5      (       d  [        S5      eXl         [        R
                  " U5      U l        [        R                  " US5        g )Nzfile descriptor must be an intF)r   
isinstancer   	TypeErrorosget_blocking_original_is_blockingset_blockingselfr   s     P/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/trio/_unix_pipes.py__init___FdHolder.__init__0   sH     "c""<==%'__R%8"
E"    c                     U R                   S:H  $ Nr   )r   r   s    r   closed_FdHolder.closed;   s    ww"}r    c                    U R                   (       a  g U R                  nSU l        [        R                  " XR                  5        [        R
                  " U5        g r"   )r$   r   r   r   r   closer   s     r   
_raw_close_FdHolder._raw_close?   s;     ;;WW
667
r    c                $    U R                  5         g N)r(   r#   s    r   __del___FdHolder.__del__N   s    r    c                    U R                   (       d:  [        R                  R                  U R                  5        U R                  5         g g r+   )r$   triolowlevelnotify_closingr   r(   r#   s    r   r'   _FdHolder.closeQ   s.    {{MM((1OO r    )r   r   Nr   r   returnNone)r4   boolr4   r5   )__name__
__module____qualname____firstlineno____annotations__r   propertyr$   r(   r,   r'   __static_attributes__ r    r   r   r      s1    $ 	G	#  r    r   c                  b    \ rS rSrSrSS jrSS jrSS jrSSS jjrSS jr	SS	 jr
SS
 jrSrg)FdStreamW   a  
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    [        U5      U l        [        S5      U l        [        S5      U l        g )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   FdStream.__init__y   s/    #B-'78(
$ +;;+
'r    c                ^  #    U R                      U R                  R                  (       a  [        R                  " S5      e[        R
                  R                  5       I S h  vN   [        U5      n[        U5       nSnXB:  aC  X4S   n U[        R                  " U R                  R                  U5      -  nS S S 5        XB:  a  MC  S S S 5        S S S 5        g  Nv! [         a?    [        R
                  R                  U R                  R                  5      I S h  vN     Nj[         aK  nUR                  [        R                   :X  a  [        R                  " S5      S e[        R"                  UeS nAff = f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g = f7f)Nfile was already closedr   )rE   rD   r$   r/   ClosedResourceErrorr0   
checkpointlen
memoryviewr   writer   BlockingIOErrorwait_writableOSErrorerrnoEBADFBrokenResourceError)r   datalengthviewsent	remaininges          r   send_allFdStream.send_all   s?    )) %%../HII--**,,,YFD!Tme	
F BHHT__-?-?$KKD % m " *)
 -  / R"&--"="=doo>P>P"QQQ& F ww%++5&*&>&>$='"'+!, '+&>&>A EF % "! *)s   F-AF"C#F=F	E:.C9FF	F-FA E7	DE7	!E:#	E7	,AE2	2E7	7E::
FF
F	F
F*&F-c                ~  #    U R                      U R                  R                  (       a  [        R                  " S5      e [        R
                  R                  U R                  R                  5      I S h  vN    S S S 5        g  N! [         a  n[        R                  UeS nAff = f! , (       d  f       g = f7f)NrI   )
rE   rD   r$   r/   rJ   r0   rP   r   BrokenPipeErrorrT   )r   rZ   s     r   wait_send_all_might_not_block&FdStream.wait_send_all_might_not_block   s     ))%%../HII6mm11$//2D2DEEE	 *) F" 6 ..A56 *)sL   B=2B,6B	8B9B	>	B=B		
B)B$$B))B,,
B:6B=Nc                  #    U R                      Uc  [        nO1[        U[        5      (       d  [	        S5      eUS:  a  [        S5      e[        R                  R                  5       I S h  vN     [        R                  " U R                  R                  U5      n UsS S S 5        $  N=! [         a?    [        R                  R                  U R                  R                  5      I S h  vN     OW[         aK  nUR                   [         R"                  :X  a  [        R$                  " S5      S e[        R&                  UeS nAff = fM  ! , (       d  f       g = f7f)Nzmax_bytes must be integer >= 1r   rI   )rF   r   r   r   r   
ValueErrorr/   r0   rK   r   readrD   r   rO   wait_readablerQ   rR   rS   rJ   rT   )r   	max_bytesrU   excs       r   receive_someFdStream.receive_some   s    ,, 0	!)S11#$DEEq=$%EFF--**,,,774??#5#5yAD 3 -, - ' J--55doo6H6HIII @yyEKK/"665#$ #66C?@  -,sm   EAE,B*-E3+B,E 
E*E,A E,C/-E2E4	E=AEEE
EEc                8    U R                   R                  5         g r+   )rD   r'   r#   s    r   r'   FdStream.close   s    r    c                |   #    U R                  5         [        R                  R                  5       I S h  vN   g  N7fr+   )r'   r/   r0   rK   r#   s    r   acloseFdStream.aclose   s$     

mm&&(((s   2<:<c                .    U R                   R                  $ r+   )rD   r   r#   s    r   filenoFdStream.fileno   s    !!!r    )rD   rF   rE   r3   )rU   bytesr4   r5   r7   r+   )re   z
int | Noner4   rq   )r4   r   )r8   r9   r:   r;   __doc__r   r[   r_   rg   r'   rl   ro   r>   r?   r    r   rA   rA   W   s,    @
F2	68 )"r    rA   )
__future__r   rR   r   systypingr   r/   _abcr   _utilr   r   r	   r   platformnameImportErrorr   r<   r   rA   r?   r    r   <module>r{      s    "  	 
     *)CLLG3 3377g  #( i '8 8v r"v r" r"r    