Run the callback periodically
498964
def run(self):
        ''''''
        while not self.wait(self.delay()):
            try:
                logger.info('Invoking callback %s', self.callback)
                self.callback()
            except StandardError:
                logger.exception('Callback failed')
645004
def run(self):
        """"""
        self.api = self.context.get("cls")(self.context)
        self.context["inst"].append(self)  # Adapters used by strategies

        for call, calldata in self.context.get("calls", {}).items():
            def loop():
                """Loop on event scheduler, calling calls"""
                while not self.stopped.wait(calldata.get("delay", None)):
                    self.call(call, calldata.get("arguments", None))

            self.thread[call] = Process(target=loop)
            self.thread[call].start()
617917
function Timer (callback, start) {
  this.callback = callback;
  this.startDate = null;
  if (!exists(start) || start !== false) {
    this.start();
  }
}
471221
def run(self):
        """"""
        resp = _wait_until(obj=self.obj, att=self.att,
                desired=self.desired, callback=None,
                interval=self.interval, attempts=self.attempts,
                verbose=False, verbose_atts=None)
        self.callback(resp)
1198396
def _run_done_callbacks(self):
        ''' 
        '''
        with self._callbacks_lock:
            for callback in self._done_callbacks:
                try:
                    callback()
                # We do not want a callback interrupting the process, especially
                # in the failure cleanups. So log and catch, the excpetion.
                except Exception as ex:
                    logger.error("Exception: %s" % str(ex))
                    logger.error("Exception raised in %s." % callback, exc_info=True)

            self._done_callbacks = []
859217
public void run() {

        while (!stop) {
            long t0 = System.currentTimeMillis();

            try {
                EventConsumer.subscribeIfNotDone();
                resubscribe_if_needed();
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            catch (Error err) {
                err.printStackTrace();
            }

            long msToSleep = EVENT_HEARTBEAT_PERIOD - (System.currentTimeMillis() - t0);
            if (msToSleep<5)
                msToSleep = 5;
            waitNextLoop(msToSleep);
        }
    }
125873
function run() {
		$fw=\Base::instance();
		// Assign signal handlers
		declare(ticks=1);
		pcntl_signal(SIGINT,[$this,'kill']);
		pcntl_signal(SIGTERM,[$this,'kill']);
		gc_enable();
		// Activate WebSocket listener
		$listen=stream_socket_server(
			$this->addr,$errno,$errstr,
			STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,
			$this->ctx
		);
		$socket=socket_import_stream($listen);
		register_shutdown_function(function() use($listen) {
			foreach ($this->sockets as $socket)
				if ($socket!=$listen)
					$this->close($socket);
			$this->close($listen);
			if (isset($this->events['stop']) &&
				is_callable($func=$this->events['stop']))
				$func($this);
		});
		if ($errstr)
			user_error($errstr,E_USER_ERROR);
		if (isset($this->events['start']) &&
			is_callable($func=$this->events['start']))
			$func($this);
		$this->sockets=[(int)$listen=>$listen];
		$empty=[];
		$wait=$this->wait;
		while (TRUE) {
			$active=$this->sockets;
			$mark=microtime(TRUE);
			$count=@stream_select(
				$active,$empty,$empty,(int)$wait,round(1e6*($wait-(int)$wait))
			);
			if (is_bool($count) && $wait) {
				if (isset($this->events['error']) &&
					is_callable($func=$this->events['error']))
					$func($this);
				die;
			}
			if ($count) {
				// Process active connections
				foreach ($active as $socket) {
					if (!is_resource($socket))
						continue;
					if ($socket==$listen) {
						if ($socket=@stream_socket_accept($listen,0))
							$this->alloc($socket);
						else
						if (isset($this->events['error']) &&
							is_callable($func=$this->events['error']))
							$func($this);
					}
					else {
						$id=(int)$socket;
						if (isset($this->agents[$id]))
							$this->agents[$id]->fetch();
					}
				}
				$wait-=microtime(TRUE)-$mark;
				while ($wait<1e-6) {
					$wait+=$this->wait;
					$count=0;
				}
			}
			if (!$count) {
				$mark=microtime(TRUE);
				foreach ($this->sockets as $id=>$socket) {
					if (!is_resource($socket))
						continue;
					if ($socket!=$listen &&
						isset($this->agents[$id]) &&
						isset($this->events['idle']) &&
						is_callable($func=$this->events['idle']))
						$func($this->agents[$id]);
				}
				$wait=$this->wait-microtime(TRUE)+$mark;
			}
			gc_collect_cycles();
		}
	}
282137
public function run()
    {
        $this->timer = new Timer($this->name, true);

        if (!is_callable($this->callback)) {
            throw new \RuntimeException('No callback provided');
        }

        call_user_func($this->callback);

        $this->timer->tick();
    }
1039743
function onload() {
		// Create pattern
		pattern = ctx.createPattern(img, params.repeat);
		// Run callback function if defined
		if (params.load) {
			params.load.call($canvases[0], pattern);
		}
	}
443447
def run(self):
    """"""

    if not (self._watchman and self._watchman.is_alive()):
      raise PantsService.ServiceError('watchman is not running, bailing!')

    # Enable watchman for the build root.
    self._watchman.watch_project(self._build_root)

    subscriptions = list(self._handlers.values())

    # Setup subscriptions and begin the main event firing loop.
    for handler_name, event_data in self._watchman.subscribed(self._build_root, subscriptions):
      self._state.maybe_pause()
      if self._state.is_terminating:
        break

      if event_data:
        # As we receive events from watchman, trigger the relevant handlers.
        self.fire_callback(handler_name, event_data)
1366942
def run_on(*, event: str):
        """"""

        def decorator(callback):
            @functools.wraps(callback)
            def decorator_wrapper():
                RTMClient.on(event=event, callback=callback)

            return decorator_wrapper()

        return decorator
55193
def run(self):
        """"""
        ret = eventlet.spawn(self.context(self.func))
        eventlet.sleep(self.seconds)
        try:
            ret.wait()
        except Exception:  # pylint: disable=broad-except
            traceback.print_exc()
        self.thread = eventlet.spawn(self.run)
277776
def on_open(self, callback, period):
        
        super().on_open()
        self.callback = callback
        self.period = period
        self.reset_event = asyncio.Event(loop=self.loop)
1273639
function (minimumInterval, callback) {
    var timeout = null;
    return function () {
        var that = this, args = arguments;
        if(timeout === null) {
            timeout = setTimeout(function () {
                timeout = null;
            }, minimumInterval);
            callback.apply(that, args);
        }
    };
}
924202
def start_heartbeat(self):
        """"""
        self.stop_heartbeat()

        self._heartbeat_timer = periodic.Callback(self._heartbeat,
                                                  self._heartbeat_interval,
                                                  self.server.io_loop)
        self._heartbeat_timer.start()
1110613
def trigger(self):
        
        self.call_back(*self.args, **self.kwargs)
        if self.__timer is not None:
            self.__timer.cancel()
1155363
def listen(cls, event, func):
        """"""
        signal(event).connect(func, sender=cls)