#NEWLINE# def error_all_requests( self , exc ) : #NEWLINE# #INDENT# with self . lock : #NEWLINE# #INDENT# requests = self . _requests #NEWLINE# self . _requests = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( not requests ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# new_exc = ConnectionShutdown ( str ( exc ) ) #NEWLINE# def try_callback( cb ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cb ( new_exc ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# log . warning ( 'Ignoring unhandled exception while erroring requests for a failed connection (%s) to host %s:' , id ( self ) , self . host , exc_info = True ) #NEWLINE# #UNINDENT# #UNINDENT# ( cb , _ ) = requests . popitem ( ) [ 1 ] #NEWLINE# try_callback ( cb ) #NEWLINE# if ( not requests ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# def err_all_callbacks( ) : #NEWLINE# #INDENT# for ( cb , _ ) in requests . values ( ) : #NEWLINE# #INDENT# try_callback ( cb ) #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( requests ) < Connection . CALLBACK_ERR_THREAD_THRESHOLD ) : #NEWLINE# #INDENT# err_all_callbacks ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# t = Thread ( target = err_all_callbacks ) #NEWLINE# t . daemon = True #NEWLINE# t . start ( )