#NEWLINE# @ asyncio . coroutine #NEWLINE# def run_as_coroutine( self , stdin , callbacks ) : #NEWLINE# #INDENT# "\n        The input 'event loop'.\n        " #NEWLINE# assert isinstance ( callbacks , EventLoopCallbacks ) #NEWLINE# stdin_reader = PosixStdinReader ( stdin . fileno ( ) ) #NEWLINE# if self . closed : #NEWLINE# #INDENT# raise Exception ( 'Event loop already closed.' ) #NEWLINE# #UNINDENT# inputstream = InputStream ( callbacks . feed_key ) #NEWLINE# try : #NEWLINE# #INDENT# self . _stopped_f = asyncio . Future ( ) #NEWLINE# def timeout_handler( ) : #NEWLINE# #INDENT# '\n                When no input has been received for INPUT_TIMEOUT seconds,\n                flush the input stream and fire the timeout event.\n                ' #NEWLINE# inputstream . flush ( ) #NEWLINE# callbacks . input_timeout ( ) #NEWLINE# #UNINDENT# timeout = AsyncioTimeout ( INPUT_TIMEOUT , timeout_handler , self . loop ) #NEWLINE# def received_winch( ) : #NEWLINE# #INDENT# self . call_from_executor ( callbacks . terminal_size_changed ) #NEWLINE# #UNINDENT# self . loop . add_signal_handler ( signal . SIGWINCH , received_winch ) #NEWLINE# def stdin_ready( ) : #NEWLINE# #INDENT# data = stdin_reader . read ( ) #NEWLINE# inputstream . feed ( data ) #NEWLINE# timeout . reset ( ) #NEWLINE# if stdin_reader . closed : #NEWLINE# #INDENT# self . stop ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . loop . add_reader ( stdin . fileno ( ) , stdin_ready ) #NEWLINE# for f in self . _stopped_f : #NEWLINE# #INDENT# ( yield f ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# self . loop . remove_reader ( stdin . fileno ( ) ) #NEWLINE# self . loop . remove_signal_handler ( signal . SIGWINCH ) #NEWLINE# timeout . stop ( )