Cleanup the DirectorySocket to original status to connect
to another Socket.
195168
@Override
    synchronized public void cleanup() {
        LOGGER.info("Cleanup the DirectorySocket.");

        if(task != null){
            task.toStop();
            task = null;
        }

        if(client != null){
            try {
                client.stop();
            } catch (Exception e) {
                LOGGER.warn("Close WebSocketClient get exception.", e);
            }
            client = null;
        }

        try {
            if(session != null){
                session.close();
            }
        } catch (IOException e) {
            LOGGER.warn("Close the WebSocket Session get exception.", e);
        }

        if(sessionFuture != null){
            try {
            sessionFuture.cancel(true);
            } catch (Exception e) {
                // do nothing
            }
        }

        session = null;
        sessionFuture = null;
        websocketStarted = false;
        connected = false;
        isStarted = false;
    }
226800
def purge(self):
        
        try:
            self._device.setblocking(0)
            while(self._device.recv(1)):
                pass
        except socket.error as err:
            pass
        finally:
            self._device.setblocking(1)
433037
def shutdown_rd(self):
        
        if self._sock_send is not None:
            self.sock.close()
        else:
            return self.shutdown(socket.SHUT_RD)
1200118
def _clean_dead_sessions(self):
        
        for sck in list(self.sessions.keys()):
            session = self.sessions[sck]
            if session.socket is None:
                del self.sessions[sck]
1030220
def Cleanup(self):
		
		self.lock.acquire()
		try:
			for bucket in self.connections.values():
				try:
					for conn in bucket:
						conn.lock()
						try:
							open = conn.TestConnection(forceCheck=True)
							if open is True:
								conn.commit()
							else:
								#Remove the connection from the pool. Its dead better of recreating it.
								index = bucket.index(conn)
								del bucket[index]
							conn.release()
						except Exception:
							conn.release()
				except Exception:
					pass
		finally:
			self.lock.release()
1147902
def close(self):
        """"""

        try:
            self.sock.shutdown(socket.SHUT_RDWR)
            self.sock.close()
        except socket.error:
            pass
2113
void cleanup() throws IOException {
    serverSocket.close();
    try {
      downlink.close();
    } catch (InterruptedException ie) {
      Thread.currentThread().interrupt();
    }      
  }
958339
def cleanup():
    """"""
    for sck in list(Wdb._sockets):
        try:
            sck.close()
        except Exception:
            log.warn('Error in cleanup', exc_info=True)
179029
def _cleanup():
    '''
    
    '''
    for inst in _ACTIVE[:]:
        res = inst.isalive()
        if res is not True:
            try:
                _ACTIVE.remove(inst)
            except ValueError:
                # This can happen if two threads create a new Terminal instance
                # It's harmless that it was already removed, so ignore.
                pass
1015148
void finishConnection() {
    NioSocketConnector conn = this.connector;
    if (conn != null) {
      this.connector = null;
      conn.dispose();
      for (ConnectionListener listener : this.connectionListeners) {
        listener.connectionEnded(this);
      }
    }
    ExecutorFilter execs = this.executors;
    if (execs != null) {
      this.executors = null;
      execs.destroy();

    }
  }
57354
public void clearRecycle()
  {
    ArrayList<ClientSocket> recycleList = null;

    synchronized (this) {
      _idleHead = _idleTail = 0;

      for (int i = 0; i < _idle.length; i++) {
        ClientSocket stream;

        stream = _idle[i];
        _idle[i] = null;

        if (stream != null) {
          if (recycleList == null)
            recycleList = new ArrayList<ClientSocket>();

          recycleList.add(stream);
        }
      }
    }

    if (recycleList != null) {
      for (ClientSocket stream : recycleList) {
        stream.closeImpl();
      }
    }
  }
811146
def stop(self, timeout_s=None):
    """"""
    self._live = False
    try:
      self._sock.shutdown(socket.SHUT_RDWR)
      self._sock.close()
    except socket.error:
      pass
    self.join(timeout_s)
1117782
def _cleanup(self):
        '''
        
        '''
        self._ack_listener = None
        self._nack_listener = None
        self._broker_cancel_cb_map = None
        super(RabbitBasicClass, self)._cleanup()
365599
function clean(directoryPath, isRoot, done) {
  fs.stat(directoryPath, function(err, stat) {
    if (err) return done(isRoot ? undefined : err);
    if (stat.isFile()) return fs.unlink(directoryPath, done);
    fs.readdir(directoryPath, function(err, relativePaths) {
      if (err) return done(err);
      each(relativePaths, function(relativePath, next) {
        var absolutePath = path.join(directoryPath, relativePath);
        fs.stat(absolutePath, function(err, stats) {
          if (err) return next(err);
          if (!stats.isDirectory()) return fs.unlink(absolutePath, next);
          clean(absolutePath, false, next);
        });
      }, function(err) {
        if (err) return done(err);
        fs.rmdir(directoryPath, done);
      });
    });
  });
}
32022
protected void dispose() {
        // Terminates the server thread
        if(serverThread != null) {
            serverThread.interrupt();
            serverThread = null;
        }

        // Stops each connection and clears them
        synchronized(connections) {
            for(FTPConnection con : connections) {
                try {
                    con.stop(true);
                } catch(Exception ex) {
                    ex.printStackTrace();
                }
            }
            connections.clear();
        }
    }
1337547
@Override
	public void cleanupConnection(ConnectionHandle oldHandle, ConnectionHandle newHandle) {
		this.threadFinalizableRefs.remove(oldHandle);
		this.threadWatch(newHandle);
	}
122719
def cleanup(self):
        """"""
        for item in self.server_map:
            self.member_del(item, reconfig=False)
        self.server_map.clear()