#NEWLINE# def _set_timeout( future , timeout ) : #NEWLINE# #INDENT# if timeout : #NEWLINE# #INDENT# def on_timeout( ) : #NEWLINE# #INDENT# future . set_exception ( gen . TimeoutError ( ) ) #NEWLINE# #UNINDENT# io_loop = ioloop . IOLoop . current ( ) #NEWLINE# timeout_handle = io_loop . add_timeout ( timeout , on_timeout ) #NEWLINE# future . add_done_callback ( ( lambda _ : io_loop . remove_timeout ( timeout_handle ) ) )