
                         ~    S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
Jr  SS	KJr  SS
KrSS
KrSr " S S\5      rg
)z
Posix asyncio event loop.
    )unicode_literals   )InputStream   )AsyncioTimeout)	EventLoopINPUT_TIMEOUT)EventLoopCallbacks)PosixStdinReaderN)PosixAsyncioEventLoopc                   j    \ rS rSrSS jr\R                  S 5       rS rS r	S r
SS jrS	 rS
 rSrg)r      Nc                     U=(       d    [         R                  " 5       U l        SU l        [         R                  " 5       U l        g )NF)asyncioget_event_looploopclosedFuture
_stopped_f)selfr   s     9lib/third_party/prompt_toolkit/eventloop/asyncio_posix.py__init__PosixAsyncioEventLoop.__init__   s,    4G224	!..*    c              #     ^ ^^^^	#    [        T[        5      (       d   e[        UR                  5       5      mT R                  (       a  [        S5      e[        TR                  5      m [        R                  " 5       T l
        UU4S jn[        [        UT R                  5      m	UU 4S jnT R                  R                  [        R                   U5        UU UU	4S jnT R                  R#                  UR                  5       U5        T R                   H  nUv   M	     T R                  R%                  UR                  5       5        T R                  R'                  [        R                   5        T	R)                  5         g! T R                  R%                  UR                  5       5        T R                  R'                  [        R                   5        T	R)                  5         f = f7f)z
The input 'event loop'.
zEvent loop already closed.c                  F   > TR                  5         T R                  5         g)zo
When no input has been received for INPUT_TIMEOUT seconds,
flush the input stream and fire the timeout event.
N)flushinput_timeout)	callbacksinputstreams   r   timeout_handler?PosixAsyncioEventLoop.run_as_coroutine.<locals>.timeout_handler/   s    
 !!#'')r   c                  <   > TR                  T R                  5        g N)call_from_executorterminal_size_changed)r   r   s   r   received_winch>PosixAsyncioEventLoop.run_as_coroutine.<locals>.received_winch;   s    ''	(G(GHr   c                     > TR                  5       n TR                  U 5        TR                  5         TR                  (       a  TR	                  5         g g r$   )readfeedresetr   stop)datar    r   stdin_readertimeouts    r   stdin_ready;PosixAsyncioEventLoop.run_as_coroutine.<locals>.stdin_readyA   sA    #((*  &  &&IIK 'r   N)
isinstancer
   r   filenor   	Exceptionr   feed_keyr   r   r   r   r	   r   add_signal_handlersignalSIGWINCH
add_readerremove_readerremove_signal_handlerr-   )
r   stdinr   r!   r'   r1   fr    r/   r0   s
   ` `    @@@r   run_as_coroutine&PosixAsyncioEventLoop.run_as_coroutine   sO    
 )%78888 (7;;899!)"4"45,	%nn.DO* %]OTYYOGI II((.I    II  = __ %
 II##ELLN3II++FOO< LLN	 II##ELLN3II++FOO< LLNs!   A"G+*B7F !A#G+A$G((G+c                 :    U R                   R                  S5        g NT)r   
set_resultr   s    r   r-   PosixAsyncioEventLoop.stopX   s    ""4(r   c                     SU l         g rB   )r   rD   s    r   closePosixAsyncioEventLoop.close\   s     r   c                 <    U R                   R                  S U5        g r$   )r   run_in_executor)r   callbacks     r   rJ   %PosixAsyncioEventLoop.run_in_executora   s    		!!$1r   c                 :    U R                   R                  U5        g)zU
Call this function in the main event loop.
Similar to Twisted's ``callFromThread``.
N)r   call_soon_threadsafe)r   rK   _max_postpone_untils      r   r%   (PosixAsyncioEventLoop.call_from_executord   s    
 			&&x0r   c                 :    U R                   R                  X5        g)z:Start watching the file descriptor for read availability. N)r   r:   )r   fdrK   s      r   r:    PosixAsyncioEventLoop.add_readerk   s    		R*r   c                 :    U R                   R                  U5        g)z9Stop watching the file descriptor for read availability. N)r   r;   )r   rR   s     r   r;   #PosixAsyncioEventLoop.remove_readero   s    		#r   )r   r   r   r$   )__name__
__module____qualname____firstlineno__r   r   	coroutiner?   r-   rG   rJ   r%   r:   r;   __static_attributes__ r   r   r   r      s@    + : :x)
21+$r   r   )__doc__
__future__r   terminal.vt100_inputr   asyncio_baser   baser   r	   r   r
   posix_utilsr   r   r8   __all__r   r\   r   r   <module>rd      s9    ( . ( * ) )  
]$I ]$r   