Return the appropriate time to wait, if we sent too many messages

        :returns: the time to wait in seconds
        :rtype: :class:`float`
        :raises: None
184401
def get_waittime(self):
        
        now = time.time()
        self.sentmessages.appendleft(now)
        if len(self.sentmessages) == self.sentmessages.maxlen:
            # check if the oldes message is older than
            # limited by self.limitinterval
            oldest = self.sentmessages[-1]
            waittime = self.limitinterval - (now - oldest)
            if waittime > 0:
                return waittime + 1  # add a little buffer
        return 0
1085498
def wait_until time_to_wait=30, &block
      time_limit = Time.now + time_to_wait
      until block.call 
        if Time.now > time_limit
          raise "wait_until timeout after #{time_to_wait} seconds"
        end
        sleep 0.1
      end
      true
    end
1212520
def wait(self, timeout=None):
    

    tbegin = _get_timeout_begin(timeout)
    with self._lock:
      while self._queue or self._running:
        remainder = _get_timeout_remainder(tbegin, timeout)
        if remainder is not None and remainder <= 0.0:
          return False  # timeout
        self._lock.wait(remainder)
      if self._shutdown:
        for worker in self._workers:
          worker.join()
    return True
1268643
def handle_delayed_messages(self):
        
        for eta, message in iter_queue(self.delay_queue):
            if eta > current_millis():
                self.delay_queue.put((eta, message))
                self.delay_queue.task_done()
                break

            queue_name = q_name(message.queue_name)
            new_message = message.copy(queue_name=queue_name)
            del new_message.options["eta"]

            self.broker.enqueue(new_message)
            self.post_process_message(message)
            self.delay_queue.task_done()
1068868
def delay(self):
        """"""
        if self.next_request_timestamp is None:
            return
        sleep_seconds = self.next_request_timestamp - time.time()
        if sleep_seconds <= 0:
            return
        message = "Sleeping: {:0.2f} seconds prior to" " call".format(
            sleep_seconds
        )
        log.debug(message)
        time.sleep(sleep_seconds)
968024
def _wait_response(self, message):
        
        if message is None or message.code != defines.Codes.CONTINUE.number:
            self.queue.put(message)
14213
def wait(self):
        
        self.wait_event = threading.Event()
        timeout = int(self.timeout) if self.timeout else None
        self.timed_out = not self.wait_event.wait(timeout)
1074549
def wait_for_event(self, event, timeout=10):
        
        return self.__handler.wait_for_event(event, timeout=timeout)
1341461
private long calcWaitTime(long clientCustomerId, @Nullable Throwable throwable) {
    long nowInMillis = dateProvider.getNowInMillis();

    long waitForMillis = 0L;
    waitForMillis = Math.max(waitForMillis, tokenWaitUntil.get() - nowInMillis);
    waitForMillis = Math.max(waitForMillis, getAccountWaitTime(clientCustomerId) - nowInMillis);

    if (waitForMillis > 0
        && maxWaitTimeOnRateExceededError > 0
        && waitForMillis > SECONDS.toMillis(maxWaitTimeOnRateExceededError)) {
      throw new RateLimiterException(
          "Need to wait too long (more than " + maxWaitTimeOnRateExceededError + " seconds).",
          throwable);
    }

    return waitForMillis;
  }
925962
def wait(self, state, timeout=-1):
        

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

        return _lxc.Container.wait(self, state, timeout)
1245205
async def message_throttled(self, message: types.Message, throttled: Throttled):
        
        handler = current_handler.get()
        dispatcher = Dispatcher.get_current()
        if handler:
            key = getattr(handler, 'throttling_key', f"{self.prefix}_{handler.__name__}")
        else:
            key = f"{self.prefix}_message"

        # Calculate how many time is left till the block ends
        delta = throttled.rate - throttled.delta

        # Prevent flooding
        if throttled.exceeded_count <= 2:
            await message.reply('Too many requests! ')

        # Sleep.
        await asyncio.sleep(delta)

        # Check lock status
        thr = await dispatcher.check_key(key)

        # If current message is not last with current key - do not send message
        if thr.exceeded_count == throttled.exceeded_count:
            await message.reply('Unlocked.')
1140974
def wait(self, timeout=0):
        
        start_time = time.time()

        # We return synchronously, so we block in a busy loop waiting for the
        # request to be done.
        while not self.is_done:
            duration = time.time() - start_time
            if timeout and duration > timeout:
                raise CloudTimeoutError(
                    "Timeout getting async value. Timeout: %d seconds" % timeout
                )
            time.sleep(0.1)

        # If we get an any status code other than a 2xx we raise an exception to the user, which can then be handled
        # accordingly.
        status_code, error_msg, payload = self.check_error()
        if not self._status_ok(status_code):
            raise CloudAsyncError("Async response for '%s' returned an error." % self.async_id,
                                  reason=error_msg,
                                  status=status_code)

        value = self.value
        if isinstance(value, six.binary_type):
            value = value.decode('utf-8')
        return value
662339
def timeout(self, timeout):
        

        if timeout is None:
            self._timeout = None  # no timeout
            return
        self._timeout = float(timeout)
1266242
def wait(self):
        
        ret = os.read(self.event_fd, 64 / 8)
        return struct.unpack('Q', ret)
680610
async def wait(sec=5, **kwargs):
    
    await asyncio.sleep(sec)
    print("{0}: Done waiting for {1} sec.".format(kwargs['rulename'], sec))
1025186
def _get_response_ms(self):
        
        response_timedelta = now() - self.log['requested_at']
        response_ms = int(response_timedelta.total_seconds() * 1000)
        return max(response_ms, 0)
812093
def on_timeout(limit, handler=handler_func, hint=None):
    
    def notify_handler(signum, frame):
        handler("'%s' is not finished in %d second(s)." % (hint, limit))

    def __decorator(function):
        def __wrapper(*args, **kwargs):
            import signal
            signal.signal(signal.SIGALRM, notify_handler)
            signal.alarm(limit)
            result = function(*args, **kwargs)
            signal.alarm(0)
            return result
        return wraps(function)(__wrapper)
    return __decorator