close the connection normally, stops the dispatch thread and closes the
 underlying connection cleanly
424812
def close
    sd_thread = nil

    @mutex.synchronize do
      return unless @czk
      inst, @czk = @czk, nil
    
      sd_thread = Thread.new(inst) do |_inst|
        stop_dispatch_thread!
        _inst.close
      end
    end

    # if we're on the event dispatch thread for some stupid reason, then don't join
    unless event_dispatch_thread?
      # hard-coded 30 second delay, don't hang forever
      if sd_thread.join(30) != sd_thread 
        logger.error { "timed out waiting for shutdown thread to exit" }
      end
    end

    nil
  end
760402
def close_connection(self):
        ""
        if self._is_connected:
            self._is_connected = False
            self._command_parser.close_when_done()
905643
void close(boolean alreadyClosed) {

        final String methodName = "close";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName, alreadyClosed);
        }

        _closed = true;

        /*
         * 238811:
         * Stop all of the listeners - do not close them as the dispatchers
         * might still be using them. Close them after the dispatchers have
         * stopped.
         */

        /*
         * We close dispatchers as soon as they are finished with so no longer have to
         * close them here.
         */

        if (!alreadyClosed) {
            for (final Iterator iterator = _listeners.values().iterator(); iterator
                            .hasNext();) {
                final SibRaListener listener = (SibRaListener) iterator.next();
                listener.stop();
            }
        }

        // The connection is closing so throw away the connection name
        SibRaDispatcher.resetMEName();

        // We want this thread to wait until all the dispatchers have finished their work
        // (which will happen when the dispatcherCount hits 0. We put the thread into a
        // wait state if there are any dispatchers still going, the thread will be notified
        // each time a dispatcher closes (when it has finished its work).
        synchronized (_dispatcherCount) {
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
                SibTr.debug(this, TRACE, "There are still " + _dispatcherCount.get() + " open dispatchers");
            }

            if (_dispatcherCount.get() > 0) {
                Long mdbQuiescingTimeout = getMDBQuiescingTimeoutProperty();
                waitForDispatchersToFinish(mdbQuiescingTimeout);
            }
        }

        /*
         * Close all of the listeners
         */
        if (!alreadyClosed) {
            for (final Iterator iterator = _listeners.values().iterator(); iterator
                            .hasNext();) {
                final SibRaListener listener = (SibRaListener) iterator.next();
                listener.close();
            }
        }
        _listeners.clear();

        /*
         * Close the connection
         */

        try {

            _connection.removeConnectionListener(_connectionListener);
            // It should be ok to call close on an already closed connection but comms
            // FFDCs thjis (processor seems ok with it though). No need to close the connection
            // again anyway so we'll check and if we are being called as part of MeTerminated or
            // connectionError then the connection will have been closed so dont close again.
            if (!alreadyClosed) {
                _connection.close();
            }

        } catch (final SIException exception) {

            FFDCFilter.processException(exception, CLASS_NAME + "."
                                                   + methodName, "1:1023:1.59", this);
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

        } catch (final SIErrorException exception) {

            FFDCFilter.processException(exception, CLASS_NAME + "."
                                                   + methodName, "1:1031:1.59", this);
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }
520375
def close(self):
        
        if getattr(self, '_connection', None):
            logger.debug('Closing sqlite connection.')
            self._connection.close()
            self._connection = None
562445
def close(self):
        
        with self.lock:
            if self.is_closed:
                return
            self.is_closed = True

        log.debug("Closing connection (%s) to %s", id(self), self.endpoint)
        reactor.callFromThread(self.connector.disconnect)
        log.debug("Closed socket to %s", self.endpoint)

        if not self.is_defunct:
            self.error_all_requests(
                ConnectionShutdown("Connection to %s was closed" % self.endpoint))
            # don't leave in-progress operations hanging
            self.connected_event.set()
125082
def close(self):
        
        # Without this thread lock, there is a window during which
        # select() can find a closed socket, leading to an EBADF error.
        with self.reactor.mutex:
            self.disconnect("Closing object")
            self.reactor._remove_connection(self)
1279662
def close_connection(self, connection, force=False):
        """"""
        if force:
            print('PostgresPooled - delegating connection closure')
            try:
                super(PostgresPooled, self).close_connection(connection,
                                                                  force)
            except self.operational_exceptions:
                print('PostgresPooled - failed closing')
            for name, conn in self.pool.iteritems():
                if conn is connection:
                    break
            del self.pool[name]
        else:
            print('PostgresPooled - refusing to close connection')
827759
public void disconnect() {
        if (this.connection == null) {
            return;
        }

        try {
            if (this.rawInputStream == null) {
                this.rawInputStream = this.connection.getInputStream();
            }

            // We need to manually read from the raw input stream in case there are any remaining bytes. There's a bug
            // where a wrapping GZIPInputStream may not read to the end of a chunked response, causing Java to not
            // return the connection to the connection pool.
            byte[] buffer = new byte[BUFFER_SIZE];
            int n = this.rawInputStream.read(buffer);
            while (n != -1) {
                n = this.rawInputStream.read(buffer);
            }
            this.rawInputStream.close();

            if (this.inputStream != null) {
                this.inputStream.close();
            }
        } catch (IOException e) {
            throw new BoxAPIException("Couldn't finish closing the connection to the Box API due to a network error or "
                + "because the stream was already closed.", e);
        }
    }
605281
public void close() {
        done = true;
        connected = false;
        synchronized (this) {
            try {
                if (socket != null) {
                    if (traceLevel >= ctrlThreshold) {
                        System.out.println("-> CLOSE");
                    }
                    socket.close();
                }
            } catch (final IOException e) { /* ignore socket close errors */
            } finally {
                socket = null;
            }
        }
    }
856567
public void close() throws IOException, InterruptedException {
    LOG.debug("closing connection");
    stream.close();
    uplink.closeConnection();
    uplink.interrupt();
    uplink.join();
  }
1024393
@Beta(SinceVersion.V1_1_0)
    public void close() {
        httpClient.dispatcher().executorService().shutdown();
        httpClient.connectionPool().evictAll();
        synchronized (httpClient.connectionPool()) {
            httpClient.connectionPool().notifyAll();
        }
        synchronized (AsyncTimeout.class) {
            AsyncTimeout.class.notifyAll();
        }
    }
317289
def close(self):
        '''
        
        '''
        if self._wrapped_connection and self._pool:
            logger.debug("Returning connection %s to pool %s" % (self._wrapped_connection, self._pool))
            self._pool.putconn(self._wrapped_connection)
            self._wrapped_connection = None
277084
def close(self):
        
        if self.connection:
            logging.info("Closing connection to {}.".format(self.host))
            self.connection.close()
            self.connection = None
885521
def stop_dispatch_thread!(timeout=2)
    logger.debug { "#{self.class}##{__method__}" }

    if @dispatcher
      if @dispatcher.join(0)
        @dispatcher = nil
        return
      end

      @mutex.synchronize do
        event_queue.graceful_close!

        # we now release the mutex so that dispatch_next_callback can grab it
        # to do what it needs to do while delivering events
        #
        @dispatch_shutdown_cond.wait

        # wait for another timeout sec for the thread to join
        until @dispatcher.join(timeout)
          logger.error { "Dispatch thread did not join cleanly, waiting" }
        end
        @dispatcher = nil
      end
    end
  end
1321350
def close(self, *, commit=True):
    
    self.core.close(self.connection, commit=commit)
    self.connection = None
    return self
425193
def __stop(self):  # pragma: no cover
        """"""

        if not self.dispatcher_thread:
            return

        logger.info('Stopping dispatcher')
        self.running = False  # graceful shutdown
        self.dispatcher_thread.join()
        self.dispatcher_thread = None
565589
void close() {

        final String methodName = "close";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, methodName);
        }

        /*
         * Cancel any ongoing dispatch
         */
        _cancelled = true;

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }

    }