+
    j,i]                       a  0 t $ R t^ RIHt ^ RIHt ^ RIHt ^ RIH	t	H
t
Ht ^ RIHtHtHtHtHt ^RIHt RR.t]! R	]]R
3,          R7      t]R R l4       tRtR]R&   ]! R4      t ! R R4      t]3R R lltR
# )z&
Implementation for async generators.
)annotations)get_running_loop)asynccontextmanager)EmptyFullQueue)AnyAsyncGeneratorCallableIterableTypeVar)run_in_executor_with_contextaclosinggenerator_to_async_generator_T_GeneratorN)boundc                    V ^8  d   QhRRRR/# )   thingr   returnz"AsyncGenerator[_T_Generator, None] )formats   "J/usr/lib/python3/dist-packages/prompt_toolkit/eventloop/async_generator.py__annotate__r      s      '    c                  "    V 5x  V P                  4       G Rj  xL
  R#  L  T P                  4       G Rj  xL 
  i ; i5i)z1Similar to `contextlib.aclosing`, in Python 3.10.N)aclose)r   s   &r   r   r      s-     
llnellns+   A% A#AA <A  Ai  intDEFAULT_BUFFER_SIZE_Tc                      ] tR t^1tRtR# )_Doner   N)__name__
__module____qualname____firstlineno____static_attributes__r   r   r   r!   r!   1   s    r   r!   c               $    V ^8  d   QhRRRRRR/# )r   get_iterablezCallable[[], Iterable[_T]]buffer_sizer   r   zAsyncGenerator[_T, None]r   )r   s   "r   r   r   5   s+     H H,HH Hr   c               ~  a aa"   Ro\        VR7      o\        4       pR V VV3R llp\        V4      p   SP                  4       p\        V\        4      '       d   MV5x  K0  RoVG Rj  xL
  R#   \         d)    TP                  RSP                  4      G Rj  xL 
 p L^i ; i L<  RoTG Rj  xL 
  i ; i5i)aA  
Turn a generator or iterable into an async generator.

This works by running the generator in a background thread.

:param get_iterable: Function that returns a generator or iterable when
    called.
:param buffer_size: Size of the queue between the async consumer and the
    synchronous generator that produces items.
F)maxsizec                   V ^8  d   QhRR/# )r   r   Noner   )r   s   "r   r   2generator_to_async_generator.<locals>.__annotate__H   s      D r   c                   <  S! 4        F@  p S'       d!      SP                  \        4       ^R7       R#   SP                  V ^R7       KB  	    SP                  \        4       ^R7       R#   \         d    S'       d    R#  Kp  i ; i  \         dK    S'       d?       SP                  \        4       ^R7       R#   \         d    S'       d    R#  K8  i ; i K  i ; i  \         d    S'       d    R#  K  i ; i    SP                  \        4       ^R7       i   \         d    S'       d      R#  K9  i ; i; i)zf
Consume the generator in background thread.
When items are received, they'll be pushed to the queue.
)timeoutN)putr!   r   )itemr(   qquittings    r   runner,generator_to_async_generator.<locals>.runnerH   sA   
	$  EE%'1E- ' dA.  '" EE%'1E-      !#" EE%'1E-    !!   EE%'1E-   s   C? A- C? B

C? C" -BB
CC? !B> >CCC? CC? "C<;C<?D=DD=D:1D=6D=9D::D=TN)	r   r   r   
get_nowaitr   run_in_executorget
isinstancer!   )r(   r)   loopr5   runner_fr2   r3   r4   s   f&    @@r   r   r   5   s      H 5AD D ,F3H?||~ $&&
    ?!11$>>>? 		  si   /B=B+ A3 B+ %B=,B)-B=3*B&B B&#B+ %B&&B+ )B=+B:3B64B::B=)__conditional_annotations____doc__
__future__r   asyncior   
contextlibr   queuer   r   r   typingr   r	   r
   r   r   utilsr   __all__r   r   r   __annotations__r   r!   r   )r=   s   @r   <module>rG      s    # $ * $ $ C C / "
 ~^CI-FG  *   S T]	 	 +H Hr   