#NEWLINE# def return_connection( self , connection ) : #NEWLINE# #INDENT# with connection . lock : #NEWLINE# #INDENT# connection . in_flight -= 1 #NEWLINE# #UNINDENT# with self . _stream_available_condition : #NEWLINE# #INDENT# self . _stream_available_condition . notify ( ) #NEWLINE# #UNINDENT# if ( ( connection . is_defunct or connection . is_closed ) and ( not is_down . signaled_error ) ) : #NEWLINE# #INDENT# log . debug ( 'Defunct or closed connection (%s) returned to pool, potentially marking host %s as down' , id ( connection ) , self . host ) #NEWLINE# is_down = self . _session . cluster . signal_connection_failure ( self . host , connection . last_error , is_host_addition = False ) #NEWLINE# connection . signaled_error = True #NEWLINE# if is_down : #NEWLINE# #INDENT# self . shutdown ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _connection = None #NEWLINE# with self . _lock : #NEWLINE# #INDENT# if self . _is_replacing : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# self . _is_replacing = True #NEWLINE# self . _session . submit ( self . _replace , connection )