#NEWLINE# def _replace( self , connection ) : #NEWLINE# #INDENT# should_replace = False #NEWLINE# with self . _lock : #NEWLINE# #INDENT# if ( connection in self . _connections ) : #NEWLINE# #INDENT# new_connections = self . _connections [ : ] #NEWLINE# new_connections . remove ( connection ) #NEWLINE# self . _connections = new_connections #NEWLINE# self . open_count -= 1 #NEWLINE# should_replace = True #NEWLINE# #UNINDENT# #UNINDENT# if should_replace : #NEWLINE# #INDENT# log . debug ( 'Replacing connection (%s) to %s' , id ( connection ) , self . host ) #NEWLINE# connection . close ( ) #NEWLINE# self . _session . submit ( self . _retrying_replace ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . debug ( 'Closing connection (%s) to %s' , id ( connection ) , self . host ) #NEWLINE# connection . close ( )