Schedule an event to be emitted after a delay.

        :param delay: number of seconds
        :param data_tuple: a 2-tuple (flavor, data)
        :return: an event object, useful for cancelling.
189369
def event_later(self, delay, data_tuple):
        
        return self._base.event_later(delay, self.make_event_data(*data_tuple))
977024
def update_data_run(self, event_to_wait_on):
        
        # with the daemon=Turue setting, this thread should
        # quit 'automatically'
        while event_to_wait_on.wait():
            event_to_wait_on.clear()
            if self.update_data_callback_kill_event.is_set():
                return
            self.update_data_func()
1074549
def wait_for_event(self, event, timeout=10):
        
        return self.__handler.wait_for_event(event, timeout=timeout)
99310
def call_later(self, delay, func, *args, **kwargs):
        
        # "quantize" the delay to the nearest bucket
        now = self._get_seconds()
        real_time = int(now + delay) * 1000
        real_time -= int(real_time % self._bucket_milliseconds)
        call = _BatchedCall(self, real_time, lambda: func(*args, **kwargs))
        try:
            self._buckets[real_time][1].append(call)
        except KeyError:
            # new bucket; need to add "actual" underlying IDelayedCall
            diff = (real_time / 1000.0) - now
            # we need to clamp this because if we quantized to the
            # nearest second, but that second is actually (slightly)
            # less than the current time 'diff' will be negative.
            delayed_call = self._create_delayed_call(
                max(0.0, diff),
                self._notify_bucket, real_time,
            )
            self._buckets[real_time] = (delayed_call, [call])
        return call
975123
def send_data(self, data, delay=COMMAND_DELAY):
        

        time_since_last_send = time.time() - self._last_send
        delay = max(0, delay - time_since_last_send)
        time.sleep(delay)  # Ensure minim recommended delay since last send

        for item in data:
            data = bytes.fromhex(str(item.zfill(2)))
            try:
                self.sock.send(data)
            except ConnectionResetError as msg:
                _LOGGER.error("Error trying to connect to Russound controller. "
                              "Check that no other device or system is using the port that "
                              "you are trying to connect to. Try resetting the bridge you are using to connect.")
                _LOGGER.error(msg)
        self._last_send = time.time()
790692
function (func, delay) {
    var timer = null;

    return function () {
      var context = this, args = arguments;

      if (timer === null) {
        timer = setTimeout(function () {
          func.apply(context, args);
          timer = null;
        }, delay);
      }
    };
  }
40936
function delay(delay, scheduler) {
    if (scheduler === void 0) {
        scheduler = _scheduler_async__WEBPACK_IMPORTED_MODULE_1__["async"];
    }
    var absoluteDelay = Object(_util_isDate__WEBPACK_IMPORTED_MODULE_2__["isDate"])(delay);
    var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
    return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
}
1220223
function _delay(tag, ms, callback) {
		/*jshint -W040:true */
		var self = this;

		tag = "" + (tag || "default");
		if (timerMap[tag] != null) {
			clearTimeout(timerMap[tag]);
			delete timerMap[tag];
			// console.log("Cancel timer '" + tag + "'");
		}
		if (ms == null || callback == null) {
			return;
		}
		// console.log("Start timer '" + tag + "'");
		timerMap[tag] = setTimeout(function() {
			// console.log("Execute timer '" + tag + "'");
			callback.call(self);
		}, +ms);
	}
409570
def delayed_retry_gen(delay_schedule=[.1, 1, 10], msg=None, timeout=None, raise_=True):
    
    import utool as ut
    import time
    if not ut.isiterable(delay_schedule):
        delay_schedule = [delay_schedule]
    tt = ut.tic()

    # First attempt is immediate
    yield 0

    for count in it.count(0):
        #print('count = %r' % (count,))
        if timeout is not None and ut.toc(tt) > timeout:
            if raise_:
                raise Exception('Retry loop timed out')
            else:
                raise StopIteration('Retry loop timed out')
        index = min(count, len(delay_schedule) - 1)
        delay = delay_schedule[index]
        time.sleep(delay)
        yield count + 1
744239
def wait(self, delay):
        
        for _ in range(0, delay):
            self._add_step((self._rec_x, self._rec_y))
693212
def call_after(lag):
  
  def decorator(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
      wrapper.timer.cancel() # Debounce
      wrapper.timer = threading.Timer(lag, func, args=args, kwargs=kwargs)
      wrapper.timer.start()
    wrapper.timer = threading.Timer(0, lambda: None) # timer.cancel now exists
    return wrapper
  return decorator
1034683
def delay_on(self):
        

        # Workaround for ev3dev/ev3dev#225.
        # 'delay_on' and 'delay_off' attributes are created when trigger is set
        # to 'timer', and destroyed when it is set to anything else.
        # This means the file cache may become outdated, and we may have to
        # reopen the file.
        for retry in (True, False):
            try:
                self._delay_on, value = self.get_attr_int(self._delay_on, 'delay_on')
                return value
            except OSError:
                if retry:
                    self._delay_on = None
                else:
                    raise
548731
def _delay(self, ms):
        
        if ms:
            self.Delay(ms)
        else:
            if self.default_delay:
                self.Delay(self.default_delay)
685622
def _iterate(self, delay=None, fromqt=False):
        
        self.runUntilCurrent()
        self.doIteration(delay, fromqt)
1182346
def delay_off(self):
        

        # Workaround for ev3dev/ev3dev#225.
        # 'delay_on' and 'delay_off' attributes are created when trigger is set
        # to 'timer', and destroyed when it is set to anything else.
        # This means the file cache may become outdated, and we may have to
        # reopen the file.
        for retry in (True, False):
            try:
                self._delay_off, value = self.get_attr_int(self._delay_off, 'delay_off')
                return value
            except OSError:
                if retry:
                    self._delay_off = None
                else:
                    raise
417530
def _do_wait(self, timeout):
        

        if self._cancelled:
            raise CancelledError()

        if not self._done:
            self._wait = True
            
            self._sigint = pyev.Signal(signal.SIGINT, self.loop, lambda watcher, events: self._cancel(), None)
            self._sigint.start()

            if timeout and timeout > 0.0:
                self._timer = pyev.Timer(timeout, 0.0, self.loop,
                                         self._clear_wait, None)
                self._timer.start()

            while self._wait and not self._done and not self._cancelled:
                self.loop.start(pyev.EVRUN_ONCE)

        if self._cancelled:
            raise CancelledError()
        elif not self._done:
            raise TimeoutError()
1330286
def events(self, from_dt=None, to_dt=None):
        
        self.refresh_client(from_dt, to_dt)
        return self.response['Event']