ó
    ¸®i¢[  ã                  óR  • % S SK Jr  S SKrS SKJrJr  S SKJrJr  SSK	J
r
Jr  SSKJr  SSKJrJr  \/ \\   4   rS	\S
'   \/ \4   rS	\S'   \" S\S9r\" S\S9r " S S5      r\R0                   " S S\5      5       r\R0                   " S S\5      5       r\R6                  R9                  SS5      \l        \R6                  R9                  SS5      \l        SS.       S$S jjrS%S jr    S&S jrS'S jr  " S S5      r! " S S\5      r" " S  S!\5      r#S(S" jr$S)S# jr%g)*é    )ÚannotationsN)Ú	AwaitableÚCallable)Ú	TypeAliasÚTypeVaré   )Ú_coreÚ_util©ÚStapledStream)ÚReceiveStreamÚ
SendStreamr   Ú	AsyncHookÚSyncHookÚSendStreamT)ÚboundÚReceiveStreamTc                  ól   • \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SSS	 jjr
SSS
 jjrSrg)Ú_UnboundedByteQueueé   c                óš   • [        5       U l        SU l        [        R                  " 5       U l        [        R                  " S5      U l        g )NFz%another task is already fetching data)	Ú	bytearrayÚ_dataÚ_closedr	   Ú
ParkingLotÚ_lotr
   ÚConflictDetectorÚ_fetch_lock©Úselfs    ÚIC:\des-py\RoboSAPF\venv\Lib\site-packages\trio/testing/_memory_streams.pyÚ__init__Ú_UnboundedByteQueue.__init__   s8   € Ü“[ˆŒ
ØˆŒÜ×$Ò$Ó&ˆŒ	Ü ×1Ò1Ø3ó
ˆÕó    c                óF   • SU l         U R                  R                  5         g ©NT)r   r   Ú
unpark_allr   s    r!   ÚcloseÚ_UnboundedByteQueue.close$   s   € ØˆŒØ�	‰	×ÑÕr$   c                óB   • [        5       U l        U R                  5         g ©N)r   r   r(   r   s    r!   Úclose_and_wipeÚ"_UnboundedByteQueue.close_and_wipe(   s   € Ü“[ˆŒ
Ø�
‰
�r$   c                ó°   • U R                   (       a  [        R                  " S5      eU =R                  U-  sl        U R                  R                  5         g )Nzvirtual connection closed)r   r	   ÚClosedResourceErrorr   r   r'   ©r    Údatas     r!   ÚputÚ_UnboundedByteQueue.put,   s9   € Ø�<�<Ü×+Ò+Ð,GÓHÐHØ�
Š
�dÑ�
Ø�	‰	×ÑÕr$   c                óZ   • Uc  g [         R                  " U5      nUS:  a  [        S5      eg )Né   úmax_bytes must be >= 1)ÚoperatorÚindexÚ
ValueError©r    Ú	max_bytess     r!   Ú_check_max_bytesÚ$_UnboundedByteQueue._check_max_bytes2   s1   € ØÑØÜ—N’N 9Ó-ˆ	Ø�q‹=ÜÐ5Ó6Ð6ð r$   c                ó  • U R                   (       d  U R                  (       d   eUc  [        U R                  5      nU R                  (       a)  U R                  S U nU R                  S U2	 U(       d   eU$ [        5       $ r+   )r   r   Úlenr   )r    r;   Úchunks      r!   Ú	_get_implÚ_UnboundedByteQueue._get_impl9   sc   € Ø�|�|˜tŸzŸzÐ)Ð)ØÑÜ˜DŸJ™J›ˆIØ�:�:Ø—J‘J˜z 	Ð*ˆEØ—
‘
˜:˜I˜:Ð&ÞˆL�5ØˆLä“;Ðr$   Nc                óø   • U R                      U R                  U5        U R                  (       d!  U R                  (       d  [        R
                  eU R                  U5      sS S S 5        $ ! , (       d  f       g = fr+   )r   r<   r   r   r	   Ú
WouldBlockrA   r:   s     r!   Ú
get_nowaitÚ_UnboundedByteQueue.get_nowaitE   sJ   € Ø×ÓØ×!Ñ! )Ô,Ø—<—<¨¯
¯
Ü×&Ñ&Ð&Ø—>‘> )Ó,÷	 ××ús   �AA+Á+
A9c              ƒ  óh  #   • U R                      U R                  U5        U R                  (       d4  U R                  (       d#  U R                  R                  5       I S h  v•N   O[        R                  " 5       I S h  v•N   U R                  U5      sS S S 5        $  N< N ! , (       d  f       g = f7fr+   )	r   r<   r   r   r   Úparkr	   Ú
checkpointrA   r:   s     r!   ÚgetÚ_UnboundedByteQueue.getL   ss   é € Ø×ÓØ×!Ñ! )Ô,Ø—<—<¨¯
¯
Ø—i‘i—n‘nÓ&×&Ñ&ä×&Ò&Ó(×(Ð(Ø—>‘> )Ó,÷ Ññ 'á(÷ ÕüsA   ‚B2�AB!Á BÁ!B!Á>BÁ?B!Â
B2ÂB!ÂB!Â!
B/Â+B2)r   r   r   r   ©ÚreturnÚNone©r1   zbytes | bytearray | memoryviewrM   rN   )r;   ú
int | NonerM   rN   ©r;   rP   rM   r   r+   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r"   r(   r,   r2   r<   rA   rE   rJ   Ú__static_attributes__© r$   r!   r   r      s/   † ô
ôôôô7ô
ö-÷-ñ -r$   r   c                  ó~   • \ rS rSrSr   S       SS jjrSS jrSS jrSS jrSS jr	SSS	 jjr
SSS
 jjrSrg)ÚMemorySendStreaméV   aŽ  An in-memory :class:`~trio.abc.SendStream`.

Args:
  send_all_hook: An async function, or None. Called from
      :meth:`send_all`. Can do whatever you like.
  wait_send_all_might_not_block_hook: An async function, or None. Called
      from :meth:`wait_send_all_might_not_block`. Can do whatever you
      like.
  close_hook: A synchronous function, or None. Called from :meth:`close`
      and :meth:`aclose`. Can do whatever you like.

.. attribute:: send_all_hook
               wait_send_all_might_not_block_hook
               close_hook

   All of these hooks are also exposed as attributes on the object, and
   you can change them at any time.

Nc                ó|   • [         R                  " S5      U l        [        5       U l        Xl        X l        X0l        g )Nú!another task is using this stream)r
   r   Ú_conflict_detectorr   Ú	_outgoingÚsend_all_hookÚ"wait_send_all_might_not_block_hookÚ
close_hook)r    r_   r`   ra   s       r!   r"   ÚMemorySendStream.__init__l   s7   € ô #(×"8Ò"8Ø/ó#
ˆÔô -Ó.ˆŒØ*ÔØ2TÔ/Ø$�r$   c              ƒ  óX  #   • U R                      [        R                  " 5       I Sh  v•N   [        R                  " 5       I Sh  v•N   U R                  R	                  U5        U R
                  b  U R                  5       I Sh  v•N   SSS5        g Nj NO N! , (       d  f       g= f7f)zmPlaces the given data into the object's internal buffer, and then
calls the :attr:`send_all_hook` (if any).

N)r]   r	   rI   r^   r2   r_   r0   s     r!   Úsend_allÚMemorySendStream.send_allz   s   é € ð ×$Ó$Ü×"Ò"Ó$×$Ð$Ü×"Ò"Ó$×$Ð$Ø�N‰N×Ñ˜tÔ$Ø×!Ñ!Ñ-Ø×(Ñ(Ó*×*Ð*÷ %Ð$Ù$Ù$ñ +÷ %Õ$üóP   ‚B*�B¨B©BÁBÁ?BÂBÂBÂ
	B*ÂBÂBÂBÂ
B'Â#B*c              ƒ  óX  #   • U R                      [        R                  " 5       I Sh  v•N   [        R                  " 5       I Sh  v•N   U R                  R	                  S5        U R
                  b  U R                  5       I Sh  v•N   SSS5        g Nj NO N! , (       d  f       g= f7f)z^Calls the :attr:`wait_send_all_might_not_block_hook` (if any), and
then returns immediately.

Nr$   )r]   r	   rI   r^   r2   r`   r   s    r!   Úwait_send_all_might_not_blockÚ.MemorySendStream.wait_send_all_might_not_blockˆ   s€   é € ð ×$Ó$Ü×"Ò"Ó$×$Ð$Ü×"Ò"Ó$×$Ð$à�N‰N×Ñ˜sÔ#Ø×6Ñ6ÑBØ×=Ñ=Ó?×?Ð?÷ %Ð$Ù$Ù$ñ @÷ %Õ$ürf   c                ót   • U R                   R                  5         U R                  b  U R                  5         gg)zNMarks this stream as closed, and then calls the :attr:`close_hook`
(if any).

N)r^   r(   ra   r   s    r!   r(   ÚMemorySendStream.close—   s-   € ð 	�‰×ÑÔØ�?‰?Ñ&Ø�O‰OÕð 'r$   c              ƒ  ój   #   • U R                  5         [        R                  " 5       I Sh  v•N   g N7f©z!Same as :meth:`close`, but async.N©r(   r	   rI   r   s    r!   ÚacloseÚMemorySendStream.aclose¨   ó    é € à�
‰
ŒÜ×ÒÓ × Ó ùó   ‚)3«1¬3c              ƒ  óT   #   • U R                   R                  U5      I Sh  v•N $  N7f)ax  Retrieves data from the internal buffer, blocking if necessary.

Args:
  max_bytes (int or None): The maximum amount of data to
      retrieve. None (the default) means to retrieve all the data
      that's present (but still blocks until at least one byte is
      available).

Returns:
  If this stream has been closed, an empty bytearray. Otherwise, the
  requested data.

N)r^   rJ   r:   s     r!   Úget_dataÚMemorySendStream.get_data­   s"   é € ð —^‘^×'Ñ'¨	Ó2×2Ð2Ñ2ùó   ‚(¡&¢(c                ó8   • U R                   R                  U5      $ )z¡Retrieves data from the internal buffer, but doesn't block.

See :meth:`get_data` for details.

Raises:
  trio.WouldBlock: if no data is available to retrieve.

)r^   rE   r:   s     r!   Úget_data_nowaitÚ MemorySendStream.get_data_nowait½   s   € ð �~‰~×(Ñ(¨Ó3Ð3r$   )r]   r^   ra   r_   r`   )NNN)r_   úAsyncHook | Noner`   rz   ra   úSyncHook | NonerM   rN   rO   rL   r+   rQ   )rR   rS   rT   rU   Ú__doc__r"   rd   rh   r(   ro   rt   rx   rV   rW   r$   r!   rY   rY   V   sa   † ñð, +/Ø?CØ&*ð	%à'ð%ð -=ð%ð $ð	%ð
 
õ%ô+ô@ôô"!ö
3÷ 	4ñ 	4r$   rY   c                  ój   • \ rS rSrSr  S     SS jjrSSS jjrSS jrSS jrSS jr	SS	 jr
S
rg)ÚMemoryReceiveStreaméÉ   aÈ  An in-memory :class:`~trio.abc.ReceiveStream`.

Args:
  receive_some_hook: An async function, or None. Called from
      :meth:`receive_some`. Can do whatever you like.
  close_hook: A synchronous function, or None. Called from :meth:`close`
      and :meth:`aclose`. Can do whatever you like.

.. attribute:: receive_some_hook
               close_hook

   Both hooks are also exposed as attributes on the object, and you can
   change them at any time.

Nc                ó~   • [         R                  " S5      U l        [        5       U l        SU l        Xl        X l        g )Nr\   F)r
   r   r]   r   Ú	_incomingr   Úreceive_some_hookra   )r    r‚   ra   s      r!   r"   ÚMemoryReceiveStream.__init__Û   s8   € ô
 #(×"8Ò"8Ø/ó#
ˆÔô -Ó.ˆŒØˆŒØ!2ÔØ$�r$   c              ƒ  óô  #   • U R                      [        R                  " 5       I Sh  v•N   [        R                  " 5       I Sh  v•N   U R                  (       a  [        R                  eU R
                  b  U R                  5       I Sh  v•N   U R                  R                  U5      I Sh  v•N nU R                  (       a  [        R                  eUsSSS5        $  N¶ N› NW N6! , (       d  f       g= f7f)zxCalls the :attr:`receive_some_hook` (if any), and then retrieves
data from the internal buffer, blocking if necessary.

N)r]   r	   rI   r   r/   r‚   r�   rJ   )r    r;   r1   s      r!   Úreceive_someÚ MemoryReceiveStream.receive_someè   s´   é € ð ×$Ó$Ü×"Ò"Ó$×$Ð$Ü×"Ò"Ó$×$Ð$Ø�|�|Ü×/Ñ/Ð/Ø×%Ñ%Ñ1Ø×,Ñ,Ó.×.Ð.ð
 Ÿ™×+Ñ+¨IÓ6×6ˆDØ�|�|Ü×/Ñ/Ð/Ø÷ %Ñ$Ù$Ù$ñ /ñ
 7÷ %Õ$üsc   ‚C8�C'¨C©C'ÁC!ÁAC'ÂC#Â"C'Â.C%Â/&C'Ã
C8ÃC'Ã!C'Ã#C'Ã%C'Ã'
C5Ã1C8c                ó‚   • SU l         U R                  R                  5         U R                  b  U R                  5         gg)zVDiscards any pending data from the internal buffer, and marks this
stream as closed.

TN)r   r�   r,   ra   r   s    r!   r(   ÚMemoryReceiveStream.closeÿ   s4   € ð
 ˆŒØ�‰×%Ñ%Ô'Ø�?‰?Ñ&Ø�O‰OÕð 'r$   c              ƒ  ój   #   • U R                  5         [        R                  " 5       I Sh  v•N   g N7frm   rn   r   s    r!   ro   ÚMemoryReceiveStream.aclose	  rq   rr   c                ó:   • U R                   R                  U5        g)z.Appends the given data to the internal buffer.N)r�   r2   r0   s     r!   Úput_dataÚMemoryReceiveStream.put_data  s   € à�‰×Ñ˜4Õ r$   c                ó8   • U R                   R                  5         g)z2Adds an end-of-file marker to the internal buffer.N)r�   r(   r   s    r!   Úput_eofÚMemoryReceiveStream.put_eof  s   € à�‰×ÑÕr$   )r   r]   r�   ra   r‚   )NN)r‚   rz   ra   r{   rM   rN   r+   rQ   rL   rO   )rR   rS   rT   rU   r|   r"   r…   r(   ro   rŒ   r�   rV   rW   r$   r!   r~   r~   É   sI   † ñð$ /3Ø&*ð%à+ð%ð $ð%ð 
õ	%öô.ô!ô
!÷r$   r~   z._memory_streamsÚ )r;   c               ó  •  U R                  U5      n U(       d  UR                  5         gUR	                  U5         g! [        R                   a     gf = f! [        R
                   a    [        R                  " S5      Sef = f)a¼  Take data out of the given :class:`MemorySendStream`'s internal buffer,
and put it into the given :class:`MemoryReceiveStream`'s internal buffer.

Args:
  memory_send_stream (MemorySendStream): The stream to get data from.
  memory_receive_stream (MemoryReceiveStream): The stream to put data into.
  max_bytes (int or None): The maximum amount of data to transfer in this
      call, or None to transfer all available data.

Returns:
  True if it successfully transferred some data, or False if there was no
  data to transfer.

This is used to implement :func:`memory_stream_one_way_pair` and
:func:`memory_stream_pair`; see the latter's docstring for an example
of how you might use it yourself.

FzMemoryReceiveStream was closedNT)rx   r	   rD   r�   rŒ   r/   ÚBrokenResourceError)Úmemory_send_streamÚmemory_receive_streamr;   r1   s       r!   Úmemory_stream_pumpr–      sŒ   € ð0Ø!×1Ñ1°)Ó<ˆðTÞØ!×)Ñ)Ô+ð
 ð "×*Ñ*¨4Õ0ð øô ×Ñó Ùðûô ×$Ñ$ó TÜ×'Ò'Ð(HÓIÈtÐSðTús   ‚? ”A ¬A ¿AÁAÁ,Bc                 óv   ^^^• [        5       m[        5       mSUU4S jjmSU4S jjn U Tl        TTl        TT4$ )u	  Create a connected, pure-Python, unidirectional stream with infinite
buffering and flexible configuration options.

You can think of this as being a no-operating-system-involved
Trio-streamsified version of :func:`os.pipe` (except that :func:`os.pipe`
returns the streams in the wrong order â€“ we follow the superior convention
that data flows from left to right).

Returns:
  A tuple (:class:`MemorySendStream`, :class:`MemoryReceiveStream`), where
  the :class:`MemorySendStream` has its hooks set up so that it calls
  :func:`memory_stream_pump` from its
  :attr:`~MemorySendStream.send_all_hook` and
  :attr:`~MemorySendStream.close_hook`.

The end result is that data automatically flows from the
:class:`MemorySendStream` to the :class:`MemoryReceiveStream`. But you're
also free to rearrange things however you like. For example, you can
temporarily set the :attr:`~MemorySendStream.send_all_hook` to None if you
want to simulate a stall in data transmission. Or see
:func:`memory_stream_pair` for a more elaborate example.

c                 ó   >• [        TT 5        g r+   )r–   )Úrecv_streamÚsend_streams   €€r!   Ú$pump_from_send_stream_to_recv_streamÚHmemory_stream_one_way_pair.<locals>.pump_from_send_stream_to_recv_streama  s   ø€ Ü˜;¨Õ4r$   c               “  ó   >#   • T " 5         g 7fr+   rW   )r›   s   €r!   Ú*async_pump_from_send_stream_to_recv_streamÚNmemory_stream_one_way_pair.<locals>.async_pump_from_send_stream_to_recv_streame  s   øé € Ù,Õ.ùs   ƒ	rL   )rY   r~   r_   ra   )rž   r›   r™   rš   s    @@@r!   Úmemory_stream_one_way_pairr    F  sB   ú€ ô0 #Ó$€KÜ%Ó'€K÷5ð 5÷/ð !K€KÔØA€KÔØ˜Ð#Ð#r$   c                óX   • U " 5       u  pU " 5       u  p4[        X5      n[        X25      nXV4$ r+   r   )Úone_way_pairÚ
pipe1_sendÚ
pipe1_recvÚ
pipe2_sendÚ
pipe2_recvÚstream1Ústream2s          r!   Ú_make_stapled_pairr©   m  s5   € ñ *›^Ñ€JÙ)›^Ñ€JÜ˜JÓ3€GÜ˜JÓ3€GØÐÐr$   c                 ó    • [        [        5      $ )aÓ  Create a connected, pure-Python, bidirectional stream with infinite
buffering and flexible configuration options.

This is a convenience function that creates two one-way streams using
:func:`memory_stream_one_way_pair`, and then uses
:class:`~trio.StapledStream` to combine them into a single bidirectional
stream.

This is like a no-operating-system-involved, Trio-streamsified version of
:func:`socket.socketpair`.

Returns:
  A pair of :class:`~trio.StapledStream` objects that are connected so
  that data automatically flows from one to the other in both directions.

After creating a stream pair, you can send data back and forth, which is
enough for simple tests::

   left, right = memory_stream_pair()
   await left.send_all(b"123")
   assert await right.receive_some() == b"123"
   await right.send_all(b"456")
   assert await left.receive_some() == b"456"

But if you read the docs for :class:`~trio.StapledStream` and
:func:`memory_stream_one_way_pair`, you'll see that all the pieces
involved in wiring this up are public APIs, so you can adjust to suit the
requirements of your tests. For example, here's how to tweak a stream so
that data flowing from left to right trickles in one byte at a time (but
data flowing from right to left proceeds at full speed)::

    left, right = memory_stream_pair()
    async def trickle():
        # left is a StapledStream, and left.send_stream is a MemorySendStream
        # right is a StapledStream, and right.recv_stream is a MemoryReceiveStream
        while memory_stream_pump(left.send_stream, right.recv_stream, max_bytes=1):
            # Pause between each byte
            await trio.sleep(1)
    # Normally this send_all_hook calls memory_stream_pump directly without
    # passing in a max_bytes. We replace it with our custom version:
    left.send_stream.send_all_hook = trickle

And here's a simple test using our modified stream objects::

    async def sender():
        await left.send_all(b"12345")
        await left.send_eof()

    async def receiver():
        async for data in right:
            print(data)

    async with trio.open_nursery() as nursery:
        nursery.start_soon(sender)
        nursery.start_soon(receiver)

By default, this will print ``b"12345"`` and then immediately exit; with
our trickle stream it instead sleeps 1 second, then prints ``b"1"``, then
sleeps 1 second, then prints ``b"2"``, etc.

Pro-tip: you can insert sleep calls (like in our example above) to
manipulate the flow of data across tasks... and then use
:class:`MockClock` and its :attr:`~MockClock.autojump_threshold`
functionality to keep your test suite running quickly.

If you want to stress test a protocol implementation, one nice trick is to
use the :mod:`random` module (preferably with a fixed seed) to move random
numbers of bytes at a time, and insert random sleeps in between them. You
can also set up a custom :attr:`~MemoryReceiveStream.receive_some_hook` if
you want to manipulate things on the receiving side, and not just the
sending side.

)r©   r    rW   r$   r!   Úmemory_stream_pairr«   z  s   € ôZ Ô8Ó9Ð9r$   c                  óh   • \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SSS
 jjrSrg	)Ú_LockstepByteQueueiÏ  c                óì   • [        5       U l        SU l        SU l        SU l        [
        R                  " 5       U l        [        R                  " S5      U l
        [        R                  " S5      U l        g )NFzanother task is already sendingz!another task is already receiving)r   r   Ú_sender_closedÚ_receiver_closedÚ_receiver_waitingr	   r   Ú_waitersr
   r   Ú_send_conflict_detectorÚ_receive_conflict_detectorr   s    r!   r"   Ú_LockstepByteQueue.__init__Ð  sa   € Ü“[ˆŒ
Ø#ˆÔØ %ˆÔØ!&ˆÔÜ×(Ò(Ó*ˆŒÜ',×'=Ò'=Ø-ó(
ˆÔ$ô +0×*@Ò*@Ø/ó+
ˆÕ'r$   c                ó8   • U R                   R                  5         g r+   )r²   r'   r   s    r!   Ú_something_happenedÚ&_LockstepByteQueue._something_happenedÝ  s   € Ø�‰× Ñ Õ"r$   c              ƒ  óø   #   •  U" 5       (       a  OGU R                   (       d  U R                  (       a  O$U R                  R                  5       I S h  v•N   MT  [        R
                  " 5       I S h  v•N   g  N$ N7fr+   )r¯   r°   r²   rH   r	   rI   )r    Úfns     r!   Ú	_wait_forÚ_LockstepByteQueue._wait_forâ  s]   é € ØÙ�t‰tØØ×"×" d×&;×&;ØØ—-‘-×$Ñ$Ó&×&Ð&ñ ô ×ÒÓ × Ñ ñ 'Ù ùs$   ‚AA:ÁA6ÁA:Á0A8Á1A:Á8A:c                ó2   • SU l         U R                  5         g r&   )r¯   r·   r   s    r!   Úclose_senderÚ_LockstepByteQueue.close_senderë  s   € Ø"ˆÔØ× Ñ Õ"r$   c                ó2   • SU l         U R                  5         g r&   )r°   r·   r   s    r!   Úclose_receiverÚ!_LockstepByteQueue.close_receiverï  s   € Ø $ˆÔØ× Ñ Õ"r$   c              ƒ  ó2  ^ #   • T R                      T R                  (       a  [        R                  eT R                  (       a  [        R
                  eT R                  (       a   eT =R                  U-  sl        T R                  5         T R                  U 4S j5      I S h  v•N   T R                  (       a  [        R                  eT R                  (       a!  T R                  (       a  [        R
                  eS S S 5        g  N`! , (       d  f       g = f7f)Nc                 ó"   >• T R                   S:H  $ ©Nr$   ©r   r   s   €r!   Ú<lambda>Ú-_LockstepByteQueue.send_all.<locals>.<lambda>ü  s   ø€ ¨¯©°sÒ):r$   )	r³   r¯   r	   r/   r°   r“   r   r·   r»   r0   s   ` r!   rd   Ú_LockstepByteQueue.send_alló  s·   øé € Ø×)Ó)Ø×"×"Ü×/Ñ/Ð/Ø×$×$Ü×/Ñ/Ð/Ø—z—zÐ!�>Ø�JŠJ˜$Ñ�JØ×$Ñ$Ô&Ø—.‘.Ô!:Ó;×;Ð;Ø×"×"Ü×/Ñ/Ð/Ø�z�z˜d×3×3Ü×/Ñ/Ð/÷ *Ð)ñ <÷ *Õ)üs0   ƒD�BDÂ#DÂ$ADÃ;	DÄDÄ
DÄDc              ƒ  ó’  ^ #   • T R                      T R                  (       a  [        R                  eT R                  (       a'  [        R
                  " 5       I S h  v•N    S S S 5        g T R                  U 4S j5      I S h  v•N   T R                  (       a  [        R                  e S S S 5        g  NV N1! , (       d  f       g = f7f)Nc                 ó   >• T R                   $ r+   )r±   r   s   €r!   rÇ   ÚB_LockstepByteQueue.wait_send_all_might_not_block.<locals>.<lambda>	  s   ø€ ¨×)?Ò)?r$   )r³   r¯   r	   r/   r°   rI   r»   r   s   `r!   rh   Ú0_LockstepByteQueue.wait_send_all_might_not_block  s‘   øé € Ø×)Ó)Ø×"×"Ü×/Ñ/Ð/Ø×$×$Ü×&Ò&Ó(×(Ð(Ø÷ *Ð)ð —.‘.Ô!?Ó@×@Ð@Ø×"×"Ü×/Ñ/Ð/ð #÷ *Ð)ñ )á@÷ *Õ)üsM   ƒC�AB6ÁB2ÁB6Á!	CÁ*B6ÂB4Â%B6Â)	CÂ2B6Â4B6Â6
CÃ CNc              ƒ  ó‚  ^ #   • T R                      Ub'  [        R                  " U5      nUS:  a  [        S5      eT R                  (       a  [
        R                  eST l        T R                  5          T R                  U 4S j5      I S h  v•N   ST l        T R                  (       a  [
        R                  eT R                  (       a9  T R                  S U nT R                  S U2	 T R                  5         UsS S S 5        $ T R                  (       d   e S S S 5        g N“! ST l        f = f! , (       d  f       g = f7f)Nr5   r6   Tc                 ó"   >• T R                   S:g  $ rÅ   rÆ   r   s   €r!   rÇ   Ú1_LockstepByteQueue.receive_some.<locals>.<lambda>  s   ø€ ¨T¯Z©Z¸3Ò->r$   Fr$   )r´   r7   r8   r9   r°   r	   r/   r±   r·   r»   r   r¯   )r    r;   Úgots   `  r!   r…   Ú_LockstepByteQueue.receive_some  s  øé € Ø×,Ó,àÑ$Ü$ŸNšN¨9Ó5�	Ø˜q“=Ü$Ð%=Ó>Ð>à×$×$Ü×/Ñ/Ð/à%)ˆDÔ"Ø×$Ñ$Ô&ð/Ø—n‘nÔ%>Ó?×?Ð?à).�Ô&Ø×$×$Ü×/Ñ/Ð/à�z�zð —j‘j  )Ð,�Ø—J‘J˜z 	˜zÐ*Ø×(Ñ(Ô*Ø÷3 -Ñ,ð6 ×*×*Ð*Ð*Ø÷9 -Ð,ñ @øà).�Õ&ú÷ -Õ,üsT   ƒD?�A#D.Á4D"ÂD ÂD"ÂA(D.Ã9
D?ÄD.Ä	D?Ä D"Ä"	D+Ä+D.Ä.
D<Ä8D?)r   r´   r°   r±   r³   r¯   r²   rL   )rº   zCallable[[], bool]rM   rN   rO   r+   ©r;   rP   rM   zbytes | bytearray)rR   rS   rT   rU   r"   r·   r»   r¾   rÁ   rd   rh   r…   rV   rW   r$   r!   r­   r­   Ï  s/   † ô
ô#ô
!ô#ô#ô0ô	0÷ñ r$   r­   c                  óF   • \ rS rSrS	S jrS
S jrS
S jrSS jrS
S jrSr	g)Ú_LockstepSendStreami-  c                ó   • Xl         g r+   ©Ú_lbq©r    Úlbqs     r!   r"   Ú_LockstepSendStream.__init__.  ó   € Ø�	r$   c                ó8   • U R                   R                  5         g r+   )rØ   r¾   r   s    r!   r(   Ú_LockstepSendStream.close1  s   € Ø�	‰	×ÑÕ r$   c              ƒ  ój   #   • U R                  5         [        R                  " 5       I S h  v•N   g  N7fr+   rn   r   s    r!   ro   Ú_LockstepSendStream.aclose4  ó    é € Ø�
‰
ŒÜ×ÒÓ × Ó ùrr   c              ƒ  óV   #   • U R                   R                  U5      I S h  v•N   g  N7fr+   )rØ   rd   r0   s     r!   rd   Ú_LockstepSendStream.send_all8  s   é € Ø�i‰i× Ñ  Ó&×&Ó&ùs   ‚)¡'¢)c              ƒ  óT   #   • U R                   R                  5       I S h  v•N   g  N7fr+   )rØ   rh   r   s    r!   rh   Ú1_LockstepSendStream.wait_send_all_might_not_block;  s   é € Ø�i‰i×5Ñ5Ó7×7Ó7ùs   ‚( &¡(r×   N©rÚ   r­   rM   rN   rL   rO   )
rR   rS   rT   rU   r"   r(   ro   rd   rh   rV   rW   r$   r!   rÕ   rÕ   -  s   † ôô!ô!ô'÷8r$   rÕ   c                  ó@   • \ rS rSrSS jrS	S jrS	S jrS
SS jjrSrg)Ú_LockstepReceiveStreami?  c                ó   • Xl         g r+   r×   rÙ   s     r!   r"   Ú_LockstepReceiveStream.__init__@  rÜ   r$   c                ó8   • U R                   R                  5         g r+   )rØ   rÁ   r   s    r!   r(   Ú_LockstepReceiveStream.closeC  s   € Ø�	‰	× Ñ Õ"r$   c              ƒ  ój   #   • U R                  5         [        R                  " 5       I S h  v•N   g  N7fr+   rn   r   s    r!   ro   Ú_LockstepReceiveStream.acloseF  rá   rr   Nc              ƒ  óT   #   • U R                   R                  U5      I S h  v•N $  N7fr+   )rØ   r…   r:   s     r!   r…   Ú#_LockstepReceiveStream.receive_someJ  s    é € Ø—Y‘Y×+Ñ+¨IÓ6×6Ð6Ñ6ùrv   r×   ræ   rL   r+   rÓ   )	rR   rS   rT   rU   r"   r(   ro   r…   rV   rW   r$   r!   rè   rè   ?  s   † ôô#ô!÷7ñ 7r$   rè   c                 óB   • [        5       n [        U 5      [        U 5      4$ )aÐ  Create a connected, pure Python, unidirectional stream where data flows
in lockstep.

Returns:
  A tuple
  (:class:`~trio.abc.SendStream`, :class:`~trio.abc.ReceiveStream`).

This stream has *absolutely no* buffering. Each call to
:meth:`~trio.abc.SendStream.send_all` will block until all the given data
has been returned by a call to
:meth:`~trio.abc.ReceiveStream.receive_some`.

This can be useful for testing flow control mechanisms in an extreme case,
or for setting up "clogged" streams to use with
:func:`check_one_way_stream` and friends.

In addition to fulfilling the :class:`~trio.abc.SendStream` and
:class:`~trio.abc.ReceiveStream` interfaces, the return objects
also have a synchronous ``close`` method.

)r­   rÕ   rè   )rÚ   s    r!   Úlockstep_stream_one_way_pairrò   N  s"   € ô. Ó
€CÜ˜sÓ#Ô%;¸CÓ%@Ð@Ð@r$   c                 ó    • [        [        5      $ )as  Create a connected, pure-Python, bidirectional stream where data flows
in lockstep.

Returns:
  A tuple (:class:`~trio.StapledStream`, :class:`~trio.StapledStream`).

This is a convenience function that creates two one-way streams using
:func:`lockstep_stream_one_way_pair`, and then uses
:class:`~trio.StapledStream` to combine them into a single bidirectional
stream.

)r©   rò   rW   r$   r!   Úlockstep_stream_pairrô   i  s   € ô  Ô:Ó;Ð;r$   )r”   rY   r•   r~   r;   rP   rM   Úbool)rM   z,tuple[MemorySendStream, MemoryReceiveStream])r¢   z0Callable[[], tuple[SendStreamT, ReceiveStreamT]]rM   z]tuple[StapledStream[SendStreamT, ReceiveStreamT], StapledStream[SendStreamT, ReceiveStreamT]])rM   zqtuple[StapledStream[MemorySendStream, MemoryReceiveStream], StapledStream[MemorySendStream, MemoryReceiveStream]])rM   z tuple[SendStream, ReceiveStream])rM   zYtuple[StapledStream[SendStream, ReceiveStream], StapledStream[SendStream, ReceiveStream]])&Ú
__future__r   r7   Úcollections.abcr   r   Útypingr   r   r‘   r	   r
   Ú_highlevel_genericr   Úabcr   r   Úobjectr   Ú__annotations__r   r   r   r   ÚfinalrY   r~   rS   Úreplacer–   r    r©   r«   r­   rÕ   rè   rò   rô   rW   r$   r!   Ú<module>rÿ      su  ðÞ "ã ß /ß %ç Ý .ß +à  I¨fÑ$5Ð 5Ñ6€	ˆ9Ó 6à˜r 6˜zÑ*€ˆ)Ó *Ù�m¨:Ñ6€ÙÐ)°Ñ?€÷<-ñ <-ð~ ‡�ôo4�zó o4ó ðo4ðd ‡�ôJ˜-ó Jó ðJð\ /×9Ñ9×AÑAØ˜óÐ Ô ð "5×!?Ñ!?×!GÑ!GØ˜ó"Ð Ô ð !ñ	#Ø(ð#à.ð#ð ð	#ð
 
õ#ôL$$ðN
ØBð
ðô
ôM:÷j[ñ [ô|8˜*ô 8ô$7˜]ô 7ôAõ6<r$   