#NEWLINE# def _prepare_handlers( self ) : #NEWLINE# #INDENT# "Prepare the I/O handlers.\n\n        :Return: (readable, writable, timeout) tuple. 'readable' is the list\n            of readable handlers, 'writable' - the list of writable handlers,\n            'timeout' the suggested maximum timeout for this loop iteration or\n            `None`\n        " #NEWLINE# timeout = None #NEWLINE# readable = [ ] #NEWLINE# writable = [ ] #NEWLINE# for handler in self . _handlers : #NEWLINE# #INDENT# if ( handler not in self . _prepared ) : #NEWLINE# #INDENT# logger . debug ( ' preparing handler: {0!r}' . format ( handler ) ) #NEWLINE# ret = handler . prepare ( ) #NEWLINE# logger . debug ( '   prepare result: {0!r}' . format ( ret ) ) #NEWLINE# if isinstance ( ret , HandlerReady ) : #NEWLINE# #INDENT# self . _prepared . add ( handler ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( ret , PrepareAgain ) : #NEWLINE# #INDENT# if ( ret . timeout is not None ) : #NEWLINE# #INDENT# if ( timeout is None ) : #NEWLINE# #INDENT# timeout = ret . timeout #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# timeout = min ( timeout , ret . timeout ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( 'Unexpected result type from prepare()' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not handler . fileno ( ) ) : #NEWLINE# #INDENT# logger . debug ( ' {0!r}: no fileno' . format ( handler ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if handler . is_readable ( ) : #NEWLINE# #INDENT# logger . debug ( ' {0!r} readable' . format ( handler ) ) #NEWLINE# readable . append ( timeout ) #NEWLINE# #UNINDENT# if handler . is_writable ( ) : #NEWLINE# #INDENT# logger . debug ( ' {0!r} writable' . format ( handler ) ) #NEWLINE# writable . append ( handler ) #NEWLINE# #UNINDENT# #UNINDENT# return ( readable , writable , timeout )