Callback called when redis closed the connection.

        The callback queue is emptied and we call each callback found
        with None or with an exception object to wake up blocked client.
348542
def _close_callback(self):
        
        while True:
            try:
                callback = self.__callback_queue.popleft()
                callback(ConnectionError("closed connection"))
            except IndexError:
                break
        if self.subscribed:
            # pubsub clients
            self._reply_list.append(ConnectionError("closed connection"))
            self._condition.notify_all()
622760
def method_missing(method, *args, &block)
      fail(Raidis::ConnectionError, 'No Redis backend found.') unless redis

      reloading_connection do
        observing_connection { redis.send(method, *args, &block) }
      end
    end
494931
def on_close(self):
        '''
        
        '''

        if self.id in self.funcserver.websocks:
            self.funcserver.websocks[self.id] = None
            ioloop = tornado.ioloop.IOLoop.instance()
            ioloop.add_callback(lambda: self.funcserver.websocks.pop(self.id, None))

        psession = self.funcserver.pysessions.get(self.pysession_id, None)
        if psession:
            psession['socks'].remove(self.id)
            if not psession['socks']:
                del self.funcserver.pysessions[self.pysession_id]
771358
function () {
    var self = this;
    if (self._stopped)
      return;
    self._stopped = true;
    _.each(self._stopHandles, function (handle) {
      handle.stop();
    });

    // Note: we *don't* use multiplexer.onFlush here because this stop
    // callback is actually invoked by the multiplexer itself when it has
    // determined that there are no handles left. So nothing is actually going
    // to get flushed (and it's probably not valid to call methods on the
    // dying multiplexer).
    _.each(self._writesToCommitWhenWeReachSteady, function (w) {
      w.committed();
    });
    self._writesToCommitWhenWeReachSteady = null;

    // Proactively drop references to potentially big things.
    self._published = null;
    self._unpublishedBuffer = null;
    self._needToFetch = null;
    self._currentlyFetching = null;
    self._oplogEntryHandle = null;
    self._listenersHandle = null;

    Package.facts && Package.facts.Facts.incrementServerFact(
      "mongo-livedata", "observe-drivers-oplog", -1);
  }
165356
def _do_close(self):
        
        AMQP_LOGGER.debug('Closed channel #%d' % self.channel_id)
        self.is_open = False
        del self.connection.channels[self.channel_id]
        self.channel_id = self.connection = None
        self.callbacks = {}
789186
def finish(self):
        
        log.info('Client disconnected: %s', self.client_ident())
        response = ':%s QUIT :EOF from client' % self.client_ident()
        for channel in self.channels.values():
            if self in channel.clients:
                # Client is gone without properly QUITing or PARTing this
                # channel.
                for client in channel.clients:
                    client.send_queue.append(response)
                channel.clients.remove(self)
        if self.nick:
            self.server.clients.pop(self.nick)
        log.info('Connection finished: %s', self.client_ident())
242782
function(callback){
        callback = callback || noop;

        if(!this._client){
            return callback();
        }
        this._client.shutdown(function(err){
            if(!this._define_connection){
                return callback(err);
            }
            this._define_connection.shutdown(function(derr){
                callback(err || derr);
            });
        }.bind(this));
    }
1126610
public static void shutdown() {
        try {
            Connections.shutdown();
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, "Shutdown redis connection pool failed", e);
        }
    }
1276434
def _on_server_disconnect(self, exception):
        """"""
        self._protocol = None
        if self._on_disconnect_callback_func and callable(self._on_disconnect_callback_func):
            self._on_disconnect_callback_func(exception)
        if self._reconnect:
            self._reconnect_cb()
1185683
protected void connectionClosed (Connection conn)
    {
        // remove this connection from our mappings (it is automatically removed from the Selector
        // when the socket is closed)
        _handlers.remove(conn.selkey);
        _connections.remove(conn.getConnectionId());
        _oflowqs.remove(conn);
        synchronized (this) {
            _stats.closes++;
        }
    }
1324890
def on_close(self):
        
        print 'Connection closed.'
        self.remove_client()
        
        client_count = len(self.get_clients().keys())
        new_client_message = '1 client disconnected, now we have %d %s!' % (client_count, 'client' if client_count <= 1 else 'clients')
        self.broadcast(new_client_message)
913319
function(self, callback) {
  if (self.pool && self.pool.isDestroyed()) {
    self.cursorState.killed = true;
    const err = new MongoNetworkError(
      f('connection to host %s:%s was destroyed', self.pool.host, self.pool.port)
    );
    _setCursorNotifiedImpl(self, () => callback(err));
    return true;
  }

  return false;
}
1197990
def disconnect(self):
        
        if not self.is_connected() and not self.is_connecting():
            return
        LOG.debug("disconnecting from %s...", self._redis_server())
        self.__periodic_callback.stop()
        try:
            self._ioloop.remove_handler(self.__socket_fileno)
            self._listened_events = 0
        except Exception:
            pass
        self.__socket_fileno = -1
        try:
            self.__socket.close()
        except Exception:
            pass
        self._state.set_disconnected()
        self._close_callback()
        LOG.debug("disconnected from %s", self._redis_server())
23404
public void shutdown() {
        if (clientList == null) {
            return;
        }
        cancelEvictor();
        for (RedisClient connection : clientList) {
            try {
                connection.shutdown();
            } catch (Exception e) {
                logger.debug(e.getMessage(), e);
            }
        }
    }
1090370
function(client, callback) {
    logger.entry('Client.stop.performDisconnect', client.id);

    // If this client is still starting, then wait until the state changes
    // before we attempt to stop.
    if (client.state === STATE_STARTING) {
      var stillConnecting = function(client) {
        logger.entry('stillConnecting', client.id);

        if (client.state === STATE_STARTING) {
          setImmediate(function() {
            stillConnecting(client);
          });
        } else {
          process.nextTick(function() {
            performDisconnect(client, callback);
          });
        }

        logger.exit('stillConnecting', client.id, null);
      };

      setImmediate(function() {
        stillConnecting(client);
      });
      logger.exit('Client.stop.performDisconnect', client.id, null);
      return;
    }

    client._setState(STATE_STOPPING);

    if (client._serviceFunctionTimeout) {
      // if we previously set a timeout to retry the serviceFunction, clear it.
      clearTimeout(client._serviceFunctionTimeout);
    }
    client._serviceFunctionTimeout = null;

    // Only disconnect when all outstanding send operations are complete
    if (client._outstandingSends.length === 0) {
      stopMessenger(client, function(client, callback) {
        logger.entry('Client.stop.performDisconnect.stopProcessing',
            client.id);
        // clear queuedSends as we are disconnecting
        var messages = [];
        while (client._queuedSends.length > 0) {
          messages.push(client._queuedSends.shift());
        }
        // call the msg callbacks in error as we have disconnected
        process.nextTick(function() {
          logger.entry('Client.stop.performDisconnect.' +
              'stopProcessing.queuedSendCallback', client.id);
          while (messages.length > 0) {
            var msg = messages.shift();
            if (msg.callback) {
              msg.callback(new StoppedError('send aborted due to client stop'));
            }
          }
          logger.exit('Client.stop.performDisconnect.' +
              'stopProcessing.queuedSendCallback', client.id, null);
        });
        // Clear the active and queued subscriptions lists as we were
        // asked to disconnect.
        logger.log('data', client.id, 'client._subscriptions:',
                   client._subscriptions);
        while (client._subscriptions.length > 0) {
          client._subscriptions.shift();
        }
        while (client._queuedSubscriptions.length > 0) {
          client._queuedSubscriptions.shift();
        }
        // Close our end of the socket
        if (client._stream) {
          client._stream.removeAllListeners('close');
          client._stream.end();
          client._stream = null;
        }
        client._queuedChunks = [];
        client._queuedChunksSize = 0;

        // Indicate that we've disconnected
        client._setState(STATE_STOPPED);
        // Remove ourself from the active client list
        var activeClient = activeClientList.get(client.id);
        if (client === activeClient) activeClientList.remove(client.id);
        setImmediate(function() {
          if (!client._firstStart) {
            client._firstStart = true;
            logger.log('emit', client.id, STATE_STOPPED);
            client.emit(STATE_STOPPED);
          }
        });
        if (callback) {
          process.nextTick(function() {
            logger.entry('Client.stop.performDisconnect.stopProcessing.' +
                'callback', client.id);
            callback.apply(client);
            logger.exit('Client.stop.performDisconnect.stopProcessing.' +
                'callback', client.id, null);
          });
        }

        logger.exit('Client.stop.performDisconnect.stopProcessing',
            client.id, null);
      }, callback);

      logger.exit('Client.stop.performDisconnect', client.id, null);
      return;
    }

    // try disconnect again
    setImmediate(performDisconnect, client, callback);

    logger.exit('Client.stop.performDisconnect', client.id, null);
  }
738933
def flush(self):
        # type: () -> None
        
        if self._closed:
            raise IOError('tried to flush closed connection')
        assert self._parentout is not None
        self._parentout.flush()
9121
def closed(self, reason):
        """"""
        self.client.remove_connection(self)
        self.protocol.connection_lost(reason)
        if not isinstance(reason, ConnectionClosed):
            logger.warn("connection closed, reason {}".format(reason))
        else:
            logger.info("connection closed")