#NEWLINE# def test_imap_timeout_exception( self ) : #NEWLINE# #INDENT# class ExceptionHandler ( ) : #NEWLINE# #INDENT# def __init__( self ) : #NEWLINE# #INDENT# self . counter = 0 #NEWLINE# #UNINDENT# def callback( self , request , exception ) : #NEWLINE# #INDENT# self . counter += 1 #NEWLINE# #UNINDENT# #UNINDENT# eh = ExceptionHandler ( ) #NEWLINE# reqs = [ grequests . get ( httpbin ( 'delay/1' ) , timeout = 0.001 ) ] #NEWLINE# list ( grequests . imap ( reqs , exception_handler = eh . callback ) ) #NEWLINE# self . assertEqual ( self . counter , 1 )