Sleeps for a dynamic duration of time as determined by set_rate() and true().
    
    :raises: BeatError: if this function is called before calling set_rate() or \
            before calling true()
501605
def sleep():
    
    if loop_duration == 0:
        raise BeatError("call beat.set_rate() before calling sleep")
    if loop_start_time == None:
        raise BeatError("call beat.true() before calling sleep")
    td = datetime.datetime.now() - loop_start_time
    duration_to_sleep = loop_duration - td.total_seconds()
    if duration_to_sleep < 0:
        raise BeatError("skipping sleep. Too much work!")
    time.sleep(duration_to_sleep)
1064184
def _client_run(self):
        
        # pylint: disable=protected-access
        self._waiting_messages = 0
        self._pending_messages = self._filter_pending()
        if self._backoff and not self._waiting_messages:
            _logger.info("Client told to backoff - sleeping for %r seconds", self._backoff)
            self._connection.sleep(self._backoff)
            self._backoff = 0
        self._connection.work()
        return True
692873
def sleep(self, delay):
        
        d = Deferred()
        self._get_loop().callLater(delay, d.callback, None)
        return d
814708
public static void sleep(long durationMillis) {
		try {
			Thread.sleep(durationMillis);
		} catch (InterruptedException e) {
			Thread.currentThread().interrupt();
		}
	}
875508
def Sleep(self, timeout):
    """"""
    if self.nanny_controller:
      self.nanny_controller.Heartbeat()

    # Split a long sleep interval into 1 second intervals so we can heartbeat.
    while timeout > 0:
      time.sleep(min(1., timeout))
      timeout -= 1
      # If the output queue is full, we are ready to do a post - no
      # point in waiting.
      if self._out_queue.Full():
        return

      if self.nanny_controller:
        self.nanny_controller.Heartbeat()
151884
def _adapt_sleep_interval(self, sent, received, queue, now):
        
        Global.LOGGER.debug("adjusting sleep interval")

        dispatched_since_last_check = sent - self.last_queue_check_count
        seconds_since_last_check = (
            now - self.last_queue_check_date).total_seconds()

        Global.LOGGER.debug(
            str(dispatched_since_last_check) + " dispatched in the last " + str(seconds_since_last_check))
        sleep_time = (seconds_since_last_check /
                      (dispatched_since_last_check + queue + 1)) * 0.75

        if sleep_time > 0.5:
            sleep_time = 0.5

        if sleep_time < 0.0001:
            sleep_time = 0.0001

        self.last_queue_check_date = now
        self.last_queue_check_count = sent

        Global.CONFIG_MANAGER.message_fetcher_sleep_interval = sleep_time

        sleep_interval_log_string = f"new sleep_interval = {sleep_time}"
        Global.LOGGER.debug(sleep_interval_log_string)

        if Global.CONFIG_MANAGER.show_stats:
            Global.LOGGER.info(sleep_interval_log_string)
117090
def trigger(self):
        ''''''
        tnow = time.time()

        if tnow < self.last_time:
            print("Warning, time moved backwards. Restarting timer.")
            self.last_time = tnow

        if self.last_time + (1.0/self.frequency) <= tnow:
            self.last_time = tnow
            return True
        return False
109647
def _wait(self, args, now, cap, consumed_history, consumed_capacity):
        
        for key in ['read', 'write']:
            if key in cap and cap[key] > 0:
                consumed_history[key].add(now, consumed_capacity[key])
                consumed = consumed_history[key].value
                if consumed > 0 and consumed >= cap[key]:
                    seconds = math.ceil(float(consumed) / cap[key])
                    LOG.debug("Rate limited throughput exceeded. Sleeping "
                              "for %d seconds.", seconds)
                    if callable(self.callback):
                        callback_args = args + (seconds,)
                        if self.callback(*callback_args):
                            continue
                    time.sleep(seconds)
334857
def code_timer(reset=False):
    ''' '''

    global CODE_TIMER
    if reset:
        CODE_TIMER = CodeTimer()
    else:
        if CODE_TIMER is None:
            return CodeTimer()
        else:
            return CODE_TIMER
460682
def until_true(timeout_seconds, interval=1, &block)
      elapsed_seconds = 0
      while elapsed_seconds < timeout_seconds && block.call != true
        elapsed_seconds += interval
        sleep(interval)
      end
      elapsed_seconds < timeout_seconds
    end
946580
def rate_limited(max_per_second):
    
    min_interval = 1.0 / float(max_per_second)

    def decorate(func):
        last_time_called = [0.0]
        rate_lock = threading.Lock()  # To support multi-threading

        def rate_limited_function(*args, **kargs):
            try:
                rate_lock.acquire(True)
                elapsed = time.clock() - last_time_called[0]
                wait_time_remaining = min_interval - elapsed
                if wait_time_remaining > 0:
                    time.sleep(wait_time_remaining)
                last_time_called[0] = time.clock()
            finally:
                rate_lock.release()
            return func(*args, **kargs)
        return rate_limited_function
    return decorate
245080
def delay(self, seconds=0, minutes=0):
        

        minutes += int(seconds / 60)
        seconds = seconds % 60
        seconds += float(minutes * 60)

        self.robot.pause()
        if not self.robot.is_simulating():
            _sleep(seconds)
        self.robot.resume()

        return self
369418
def every(minutes=NOTSET, seconds=NOTSET):
    
    def wrapper(func):
        # mark the function with variable 'is_cronjob=True', the function would be
        # collected into the list Handler._cron_jobs by meta class
        func.is_cronjob = True

        # collect interval and unify to seconds, it's used in meta class. See the
        # comments in meta class.
        func.tick = minutes * 60 + seconds
        return func

    if inspect.isfunction(minutes):
        func = minutes
        minutes = 1
        seconds = 0
        return wrapper(func)

    if minutes is NOTSET:
        if seconds is NOTSET:
            minutes = 1
            seconds = 0
        else:
            minutes = 0
    if seconds is NOTSET:
        seconds = 0

    return wrapper
377905
def on_for_seconds(self, speed, seconds, brake=True, block=True):
        

        if seconds < 0:
            raise ValueError("seconds is negative ({})".format(seconds))

        speed = self._speed_native_units(speed)
        self.speed_sp = int(round(speed))
        self.time_sp = int(seconds * 1000)
        self._set_brake(brake)
        self.run_timed()

        if block:
            self.wait_until('running', timeout=WAIT_RUNNING_TIMEOUT)
            self.wait_until_not_moving()
1163296
def sleep(self, time):
        
        try:
            task = asyncio.ensure_future(self.core.sleep(time))
            self.loop.run_until_complete(task)

        except asyncio.CancelledError:
            pass
        except RuntimeError:
            pass
887935
def watchdog(sleep_interval):
    
    mtimes = {}
    worker_process = restart_with_reloader()
    signal.signal(
        signal.SIGTERM, lambda *args: kill_program_completly(worker_process)
    )
    signal.signal(
        signal.SIGINT, lambda *args: kill_program_completly(worker_process)
    )
    while True:
        for filename in _iter_module_files():
            try:
                mtime = os.stat(filename).st_mtime
            except OSError:
                continue

            old_time = mtimes.get(filename)
            if old_time is None:
                mtimes[filename] = mtime
                continue
            elif mtime > old_time:
                kill_process_children(worker_process.pid)
                worker_process.terminate()
                worker_process = restart_with_reloader()
                mtimes[filename] = mtime
                break

        sleep(sleep_interval)
1171425
async function sleep(seconds) {
    let ms = seconds * 1000;
    while (ms > _maxTimeout) {
        // Support sleeping longer than the javascript max setTimeout...
        await new Promise(resolve => setTimeout(resolve, _maxTimeout));
        ms -= _maxTimeout;
    }
    return await new Promise(resolve => setTimeout(resolve, ms, seconds));
}