ó
    ¸®i~  ã            
      óÜ   • S SK Jr  S SKJrJrJr  S SKrS SKrS SKJ	r	  SSK
JrJrJrJr  \" S\S9r\" S	\S9rSS
 jrSS jr\	\R&                  " SSS9 " S S\\\\4   5      5       5       rg)é    )Úannotations)ÚGenericÚ	TypeGuardÚTypeVarN)Úfinalé   )ÚAsyncResourceÚHalfCloseableStreamÚReceiveStreamÚ
SendStreamÚSendStreamT)ÚboundÚReceiveStreamTc              ƒ  ó¼   #   • [         R                  " 5        nUR                  SS9  U R                  5       I Sh  v•N   SSS5        g N! , (       d  f       g= f7f)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)ÚresourceÚcss     ÚDC:\des-py\RoboSAPF\venv\Lib\site-packages\trio/_highlevel_generic.pyÚaclose_forcefullyr      sG   é € ô2 
×	Ò	Ô	˜rØ
�	‰	Ð=ˆ	Ñ>Ø�o‰oÓ×Ð÷ 
Ð	á÷ 
Õ	üs,   ‚A˜#A»A	¼AÁ 	AÁ	AÁ
AÁAc                ó   • [        U S5      $ )z,Check if the stream has a send_eof() method.Úsend_eof)Úhasattr)Ústreams    r   Ú_is_halfclosabler   .   s   € ä�6˜:Ó&Ð&ó    F)ÚeqÚslotsc                  ód   • \ rS rSr% SrS\S'   S\S'   SS jrSS jrSS	 jrSSS jjr	SS jr
Srg
)ÚStapledStreamé3   a>  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_streamc              ƒ  óT   #   • U R                   R                  U5      I Sh  v•N $  N7f)z$Calls ``self.send_stream.send_all``.N)r%   Úsend_all)ÚselfÚdatas     r   r(   ÚStapledStream.send_all^   s"   é € à×%Ñ%×.Ñ.¨tÓ4×4Ð4Ñ4ùó   ‚(¡&¢(c              ƒ  óR   #   • U R                   R                  5       I Sh  v•N $  N7f)z9Calls ``self.send_stream.wait_send_all_might_not_block``.N)r%   Úwait_send_all_might_not_block©r)   s    r   r.   Ú+StapledStream.wait_send_all_might_not_blockb   s    é € à×%Ñ%×CÑCÓE×EÐEÑEùs   ‚' %¡'c              ƒ  óª   #   • U R                   n[        U5      (       a  UR                  5       I Sh  v•N $ UR                  5       I Sh  v•N $  N N7f)zí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   ÚStapledStream.send_eoff   sD   é € ð ×!Ñ!ˆÜ˜F×#Ñ#ØŸ™Ó*×*Ð*àŸ™›×(Ð(ñ +á(ùs!   ‚0A²A³AÁ
AÁAÁANc              ƒ  óT   #   • U R                   R                  U5      I Sh  v•N $  N7f)z+Calls ``self.receive_stream.receive_some``.N)r&   Úreceive_some)r)   Ú	max_bytess     r   r4   ÚStapledStream.receive_somet   s"   é € à×(Ñ(×5Ñ5°iÓ@×@Ð@Ñ@ùr,   c              ƒ  óî   #   •  U R                   R                  5       I Sh  v•N   U R                  R                  5       I Sh  v•N   g N' N! U R                  R                  5       I Sh  v•N    f = f7f)z,Calls ``aclose`` on both underlying streams.N)r%   r   r&   r/   s    r   r   ÚStapledStream.aclosex   sZ   é € ð	/Ø×"Ñ"×)Ñ)Ó+×+Ð+à×%Ñ%×,Ñ,Ó.×.Ñ.ñ ,á.ø�$×%Ñ%×,Ñ,Ó.×.Ò.üsI   ‚A5„A ¡A	¢A ¦A5ÁAÁA5Á	A ÁA5ÁA2Á+A.Á,A2Á2A5© )r*   zbytes | bytearray | memoryviewÚreturnÚNone)r:   r;   )N)r5   z
int | Noner:   Úbytes)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r(   r.   r   r4   r   Ú__static_attributes__r9   r   r   r#   r#   3   s1   ‡ ñ ðD ÓØ"Ó"ô5ôFô)öA÷/r   r#   )r   r	   r:   r;   )r   r   r:   zTypeGuard[HalfCloseableStream])Ú
__future__r   Útypingr   r   r   Úattrsr   Ú
trio._utilr   Úabcr	   r
   r   r   r   r   r   r   Údefiner#   r9   r   r   Ú<module>rJ      s   ðÝ "ç .Ñ .ã ã Ý ç NÓ Ná�m¨:Ñ6€ÙÐ)°Ñ?€ô ô<'ð
 Ø‡‚�˜eÑ$ôH/ØØˆK˜Ð'Ñ(óH/ó %ó ñH/r   