§
    ¯õi~  ã            
      ó  — d dl mZ d dlmZmZmZ d dlZd dlZd dlm	Z	 ddl
mZmZmZmZ  ede¬¦  «        Z ed	e¬¦  «        Zdd„Zdd„Ze	 ej        dd¬¦  «         G d„ deeeef         ¦  «        ¦   «         ¦   «         ZdS )é    )Úannotations)ÚGenericÚ	TypeGuardÚTypeVarN)Úfinalé   )ÚAsyncResourceÚHalfCloseableStreamÚReceiveStreamÚ
SendStreamÚSendStreamT)ÚboundÚReceiveStreamTÚresourcer	   ÚreturnÚNonec              ƒ  óÂ   K  — t          j        ¦   «         5 }|                     d¬¦  «         |                      ¦   «         ƒ d{V —† ddd¦  «         dS # 1 swxY w Y   dS )aë  Close an async resource or async generator immediately, without
    blocking to do any graceful cleanup.

    :class:`~trio.abc.AsyncResource` objects guarantee that if their
    :meth:`~trio.abc.AsyncResource.aclose` method is cancelled, then they will
    still close the resource (albeit in a potentially ungraceful
    fashion). :func:`aclose_forcefully` is a convenience function that
    exploits this behavior to let you force a resource to be closed without
    blocking: it works by calling ``await resource.aclose()`` and then
    cancelling it immediately.

    Most users won't need this, but it may be useful on cleanup paths where
    you can't afford to block, or if you want to close a resource and don't
    care about handling it gracefully. For example, if
    :class:`~trio.SSLStream` encounters an error and cannot perform its
    own graceful close, then there's no point in waiting to gracefully shut
    down the underlying transport either, so it calls ``await
    aclose_forcefully(self.transport_stream)``.

    Note that this function is async, and that it acts as a checkpoint, but
    unlike most async functions it cannot block indefinitely (at least,
    assuming the underlying resource object is correctly implemented).

    z"cancelled during aclose_forcefully)ÚreasonN)ÚtrioÚCancelScopeÚcancelÚaclose)r   Úcss     úc/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/trio/_highlevel_generic.pyÚaclose_forcefullyr      s¯   è è € õ2 
Ô	Ñ	Ô	ð  ˜rØ
�	Š	Ð=ˆ	Ñ>Ô>Ð>Ø�oŠoÑÔÐÐÐÐÐÐÐð ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  ð  ð  s   –1AÁAÁAÚstreamr   úTypeGuard[HalfCloseableStream]c                ó"   — t          | d¦  «        S )z,Check if the stream has a send_eof() method.Úsend_eof)Úhasattr)r   s    r   Ú_is_halfclosabler!   .   s   € å�6˜:Ñ&Ô&Ð&ó    F)ÚeqÚslotsc                  óR   — e Zd ZU dZded<   ded<   dd
„Zdd„Zdd„Zddd„Zdd„Z	dS )ÚStapledStreama–  This class `staples <https://en.wikipedia.org/wiki/Staple_(fastener)>`__
    together two unidirectional streams to make single bidirectional stream.

    Args:
      send_stream (~trio.abc.SendStream): The stream to use for sending.
      receive_stream (~trio.abc.ReceiveStream): The stream to use for
          receiving.

    Example:

       A silly way to make a stream that echoes back whatever you write to
       it::

          left, right = trio.testing.memory_stream_pair()
          echo_stream = StapledStream(SocketStream(left), SocketStream(right))
          await echo_stream.send_all(b"x")
          assert await echo_stream.receive_some() == b"x"

    :class:`StapledStream` objects implement the methods in the
    :class:`~trio.abc.HalfCloseableStream` interface. They also have two
    additional public attributes:

    .. attribute:: send_stream

       The underlying :class:`~trio.abc.SendStream`. :meth:`send_all` and
       :meth:`wait_send_all_might_not_block` are delegated to this object.

    .. attribute:: receive_stream

       The underlying :class:`~trio.abc.ReceiveStream`. :meth:`receive_some`
       is delegated to this object.

    r   Úsend_streamr   Úreceive_streamÚdataúbytes | bytearray | memoryviewr   r   c              ƒ  óF   K  — | j                              |¦  «        ƒ d{V —†S )z$Calls ``self.send_stream.send_all``.N)r'   Úsend_all)Úselfr)   s     r   r,   zStapledStream.send_all^   s/   è è € àÔ%×.Ò.¨tÑ4Ô4Ð4Ð4Ð4Ð4Ð4Ð4Ð4r"   c              ƒ  óD   K  — | j                              ¦   «         ƒ d{V —†S )z9Calls ``self.send_stream.wait_send_all_might_not_block``.N)r'   Úwait_send_all_might_not_block©r-   s    r   r/   z+StapledStream.wait_send_all_might_not_blockb   s-   è è € àÔ%×CÒCÑEÔEÐEÐEÐEÐEÐEÐEÐEr"   c              ƒ  óš   K  — | j         }t          |¦  «        r|                     ¦   «         ƒ d{V —†S |                     ¦   «         ƒ d{V —†S )a  Shuts down the send side of the stream.

        If :meth:`self.send_stream.send_eof() <trio.abc.HalfCloseableStream.send_eof>` exists,
        then this calls it. Otherwise, this calls
        :meth:`self.send_stream.aclose() <trio.abc.AsyncResource.aclose>`.
        N)r'   r!   r   r   )r-   r   s     r   r   zStapledStream.send_eoff   sb   è è € ð Ô!ˆÝ˜FÑ#Ô#ð 	)ØŸšÑ*Ô*Ð*Ð*Ð*Ð*Ð*Ð*Ð*àŸš™œÐ(Ð(Ð(Ð(Ð(Ð(Ð(r"   NÚ	max_bytesú
int | NoneÚbytesc              ƒ  óF   K  — | j                              |¦  «        ƒ d{V —†S )z+Calls ``self.receive_stream.receive_some``.N)r(   Úreceive_some)r-   r2   s     r   r6   zStapledStream.receive_somet   s/   è è € àÔ(×5Ò5°iÑ@Ô@Ð@Ð@Ð@Ð@Ð@Ð@Ð@r"   c              ƒ  óÐ   K  — 	 | j                              ¦   «         ƒ d{V —† | j                             ¦   «         ƒ d{V —† dS # | j                             ¦   «         ƒ d{V —† w xY w)z,Calls ``aclose`` on both underlying streams.N)r'   r   r(   r0   s    r   r   zStapledStream.aclosex   sŒ   è è € ð	/ØÔ"×)Ò)Ñ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+Ð+àÔ%×,Ò,Ñ.Ô.Ð.Ð.Ð.Ð.Ð.Ð.Ð.Ð.Ð.ø�$Ô%×,Ò,Ñ.Ô.Ð.Ð.Ð.Ð.Ð.Ð.Ð.Ð.øøøs   „A Á!A%)r)   r*   r   r   )r   r   )N)r2   r3   r   r4   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r,   r/   r   r6   r   © r"   r   r&   r&   3   s­   € € € € € € ð ð  ðD ÐÐÑØ"Ð"Ð"Ñ"ð5ð 5ð 5ð 5ðFð Fð Fð Fð)ð )ð )ð )ðAð Að Að Að Að/ð /ð /ð /ð /ð /r"   r&   )r   r	   r   r   )r   r   r   r   )Ú
__future__r   Útypingr   r   r   Úattrsr   Ú
trio._utilr   Úabcr	   r
   r   r   r   r   r   r!   Údefiner&   r=   r"   r   ú<module>rD      sB  ðØ "Ð "Ð "Ð "Ð "Ð "à .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à €€€à €€€Ø Ð Ð Ð Ð Ð à NÐ NÐ NÐ NÐ NÐ NÐ NÐ NÐ NÐ NÐ NÐ Nàˆg�m¨:Ð6Ñ6Ô6€Ø�Ð)°Ð?Ñ?Ô?€ð ð  ð  ð  ð<'ð 'ð 'ð 'ð
 Ø€„�˜eÐ$Ñ$Ô$ðH/ð H/ð H/ð H/ð H/ØØˆK˜Ð'Ô(ñH/ô H/ñ %Ô$ñ „ðH/ð H/ð H/r"   