def _finalize_fairy(connection, connection_record, pool, ref, echo, fairy=None):
 _refs.discard(connection_record)
 if ((ref is not None) and (connection_record.fairy_ref is not ref)):
  return
 if (connection is not None):
  if (connection_record and echo):
   pool.logger.debug('Connection %r being returned to pool', connection)
  try:
   fairy = (fairy or _ConnectionFairy(connection, connection_record))
   assert (fairy.connection is connection)
   fairy._reset(pool, echo)
   if (not connection_record):
    pool._close_connection(connection)
  except Exception as e:
   if connection_record:
    connection_record.invalidate(e=e)
   if isinstance(e, (SystemExit, KeyboardInterrupt)):
    raise
 if connection_record:
  connection_record.checkin()

def _finalize_fairy ( connection , connection_record , pool , ref , echo , fairy = None ) : _refs . discard ( connection_record ) if ( ( ref is not None ) and ( connection_record . fairy_ref is not ref ) ) : return if ( connection is not None ) : if ( connection_record and echo ) : pool . logger . debug ( 'Connection %r being returned to pool' , connection ) try : fairy = ( fairy or _ConnectionFairy ( connection , connection_record ) ) assert ( fairy . connection is connection ) fairy . _reset ( pool , echo ) if ( not connection_record ) : pool . _close_connection ( connection ) except Exception as e : if connection_record : connection_record . invalidate ( e = e ) if isinstance ( e , ( SystemExit , KeyboardInterrupt ) ) : raise if connection_record : connection_record . checkin ( )
cleanup for a :class: .