Wait until the connection state will change to {@link #STATE_DISCONNECTED} or until
an error occurs.
963670
protected void waitUntilDisconnected() {
		try {
			synchronized (mLock) {
				while (mConnectionState != STATE_DISCONNECTED && mError == 0)
					mLock.wait();
			}
		} catch (final InterruptedException e) {
			loge("Sleeping interrupted", e);
		}
	}
309540
protected final void waitForDeliverySync()
    {
    	List<AbstractSession> sessionsSnapshot = new ArrayList<>(sessions.size());
        synchronized (sessions)
        {
        	sessionsSnapshot.addAll(sessions.values());
        }
        for(int n=0;n<sessionsSnapshot.size();n++)
        {
            AbstractSession session = sessionsSnapshot.get(n);
            session.waitForDeliverySync();
        }
    }
1037658
def wait(self):
        
        if self._status is not TaskStatus.STARTED:
            raise RuntimeError("Cannot wait on %s in state %s" %
                               (self, self._status))
        self._wait()
        self.stop()
        return self.return_values
1081655
private synchronized void waitNextLoop(long ms) {
        try {
            wait(ms);
        } catch (InterruptedException e) {
            System.err.println(e);
        }
    }
471765
def _wait_until_connectable(self, timeout=30):
        """"""
        count = 0
        while not utils.is_connectable(self.profile.port):
            if self.process.poll() is not None:
                # Browser has exited
                raise WebDriverException(
                    "The browser appears to have exited "
                    "before we could connect. If you specified a log_file in "
                    "the FirefoxBinary constructor, check it for details.")
            if count >= timeout:
                self.kill()
                raise WebDriverException(
                    "Can't load the profile. Possible firefox version mismatch. "
                    "You must use GeckoDriver instead for Firefox 48+. Profile "
                    "Dir: %s If you specified a log_file in the "
                    "FirefoxBinary constructor, check it for details."
                    % (self.profile.path))
            count += 1
            time.sleep(1)
        return True
1019406
@Override
  protected void processConnection(WatchedEvent event) {
    super.processConnection(event);
    switch (event.getState()) {
    case Disconnected:
      if (beenActiveMaster) {
        LOG.fatal(hostPort.getHostPort()
            + " disconnected from ZooKeeper, stop serving and exit immediately");
        System.exit(0);
      } else {
        LOG.warn(hostPort.getHostPort()
            + " disconnected from ZooKeeper, wait to sync and try to become active master");
      }
      break;
    default:
      break;
    }
  }
464171
public void onFailedUpgrade() {
        assert (this.state == ConnectionState.CONNECTING);
        ConnectionState event = null;
        synchronized (this) {
            this.state = ConnectionState.CLOSED;
            cleanClose = false;
            inputAvailable = false;
            outputAvailable = false;
            event = this.state;
        }
        notifyStateListeners(event);
    }
254928
void waitForSyncEnd(String peerId)
      throws TimeoutException, IOException, InterruptedException {
    MessageTuple tuple = filter.getExpectedMessage(MessageType.SYNC_END,
                                                   peerId,
                                                   getSyncTimeoutMs());
    ClusterConfiguration cnf
      = ClusterConfiguration.fromProto(tuple.getMessage().getConfig(),
                                       this.serverId);
    LOG.debug("Got SYNC_END {} from {}", cnf, peerId);
    this.persistence.setLastSeenConfig(cnf);
    if (persistence.isInStateTransfer()) {
      persistence.endStateTransfer();
    }
    // If the synchronization is performed by truncation, then it's possible
    // the content of cluster_config has been truncated in log, then we'll
    // delete these invalid cluster_config files.
    persistence.cleanupClusterConfigFiles();
  }
1322335
public void waitForExit() throws InterruptedException {
        try {
            dockerClient.waitContainer(container.id());
        } catch (DockerException e) {
            throw new IllegalStateException(e);
        }
    }
959336
def disconnect(self):
        
        if self._state == _State.CONNECTED:
            self._state = _State.DISCONNECTING
            self._transport.loseConnection()
            return self._notify_on_disconnect()
        if self._state == _State.CONNECTING:
            return fail(ClientConnecting())
        elif self._state == _State.NOT_CONNECTED:
            return succeed(None)
        elif self._state == _State.DISCONNECTING:
            return self._notify_on_disconnect()
78213
protected Promise disconnect() {
		int s = status.get();
		if (s != STATUS_DISCONNECTED && s != STATUS_DISCONNECTING) {
			status.set(STATUS_DISCONNECTING);
			if (clientSub != null) {
				clientSub.disconnect();
			}
			if (clientPub != null) {
				clientPub.disconnect();
			}
			status.set(STATUS_DISCONNECTED);
		}
		return Promise.resolve();
	}
644947
public synchronized void waitForData() {
        while (this.flushers.isEmpty() && this.isNotStopped()) {
            try {
                this.wait();
            } catch (final InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new RuntimeException(e);
            }
        }
    }
925962
def wait(self, state, timeout=-1):
        

        if isinstance(state, str):
            state = state.upper()

        return _lxc.Container.wait(self, state, timeout)
65055
async def wait_for_connection_lost(self) -> bool:
        
        if not self.connection_lost_waiter.done():
            try:
                await asyncio.wait_for(
                    asyncio.shield(self.connection_lost_waiter),
                    self.close_timeout,
                    loop=self.loop,
                )
            except asyncio.TimeoutError:
                pass
        # Re-check self.connection_lost_waiter.done() synchronously because
        # connection_lost() could run between the moment the timeout occurs
        # and the moment this coroutine resumes running.
        return self.connection_lost_waiter.done()
768978
@Override
    public void waitForData(long timeout, TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException {
        try {
            if (isDataAvailable()) {
                return;
            }
            long startTime = System.currentTimeMillis();
            getDataFuture().get(timeout, timeUnit);
            long partialTimeout = timeUnit.toMillis(timeout) - (System.currentTimeMillis() - startTime);
            if (partialTimeout <= 0) {
                throw new java.util.concurrent.TimeoutException("Data timeout is reached!");
            }
            dataObservable.waitForValue(partialTimeout, TimeUnit.MILLISECONDS);
        } catch (java.util.concurrent.TimeoutException | CouldNotPerformException | ExecutionException | CancellationException ex) {
            if (shutdownInitiated) {
                throw new InterruptedException("Interrupt request because system shutdown was initiated!");
            }
            throw new NotAvailableException("Data is not yet available!", ex);
        }
    }
115941
public void checkWaitingConnection() throws SQLException {
    if (isSecondaryHostFail()) {
      proxy.lock.lock();
      try {
        Protocol waitingProtocol = waitNewSecondaryProtocol.getAndSet(null);
        if (waitingProtocol != null && pingSecondaryProtocol(waitingProtocol)) {
          lockAndSwitchSecondary(waitingProtocol);
        }
      } finally {
        proxy.lock.unlock();
      }
    }

    if (isMasterHostFail()) {
      proxy.lock.lock();
      try {
        Protocol waitingProtocol = waitNewMasterProtocol.getAndSet(null);
        if (waitingProtocol != null && pingMasterProtocol(waitingProtocol)) {
          lockAndSwitchMaster(waitingProtocol);
        }
      } finally {
        proxy.lock.unlock();
      }
    }
  }
185720
public void onConnected() {
        ConnectionState event = null;
        synchronized (this) {
            if (this.state != ConnectionState.CONNECTING) {
                LOG.debug("Unable to set to connected, not in CONNECTING state: {}", this.state);
                return;
            }

            this.state = ConnectionState.CONNECTED;
            inputAvailable = false; // cannot read (yet)
            outputAvailable = true; // write allowed
            event = this.state;
        }
        notifyStateListeners(event);
    }