Run the task to refresh calendar events.
504895
public function execute() {
        global $CFG;

        require_once($CFG->dirroot . '/course/lib.php');

        // Specific list of plugins that need to be refreshed. If not set, then all mod plugins will be refreshed.
        $pluginstorefresh = null;
        if (isset($this->get_custom_data()->plugins)) {
            $pluginstorefresh = $this->get_custom_data()->plugins;
        }

        // Is course id set?
        if (isset($this->get_custom_data()->courseid)) {
            $courseid = $this->get_custom_data()->courseid;
        } else {
            $courseid = 0;
        }

        $pluginmanager = core_plugin_manager::instance();
        $modplugins = $pluginmanager->get_plugins_of_type('mod');
        foreach ($modplugins as $plugin) {
            // Check if a specific list of plugins is defined and check if it contains the plugin that is currently being evaluated.
            if (!empty($pluginstorefresh) && !in_array($plugin->name, $pluginstorefresh)) {
                // This plugin is not in the list, move on to the next one.
                continue;
            }
            // Refresh events.
            mtrace('Refreshing events for ' . $plugin->name);
            course_module_bulk_update_calendar_events($plugin->name, $courseid);
        }
    }
711420
def run(self):
    """"""
    while True:
      try:
        self._poll_for_update()
      except RuntimeError as error:
        # Note that because logging triggers a call to notify_update(), by
        # logging a message, we automatically retry publishing the update
        # after an error occurs.
        if error.message == 'dictionary changed size during iteration':
          # These errors occur occasionally and it is infeasible to get rid of
          # them entirely unless data.convert_to_base_types() is made
          # thread-safe. Ignore the error and retry quickly.
          _LOG.debug('Ignoring (probably harmless) error in station watcher: '
                     '`dictionary changed size during iteration`.')
          time.sleep(0.1)
        else:
          _LOG.exception('Error in station watcher: %s', error)
          time.sleep(1)
      except Exception as error:  # pylint: disable=broad-except
        _LOG.exception('Error in station watcher: %s', error)
        time.sleep(1)
695964
private void scheduleReload() {

        if (!isReloadScheduled() && (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT)) {
            // only schedule a reload if the system is not going down already
            m_threadCount++;
            Thread thread = new Thread("Bundle reload Thread " + m_threadCount) {

                @Override
                public void run() {

                    setReloadScheduled(true);
                    try {
                        Thread.sleep(1000);
                    } catch (Exception e) {
                        // ignore
                    }
                    if (isReloadScheduled()) {
                        reload(false);
                    }
                    setReloadScheduled(false);
                }
            };
            thread.start();
        }
    }
49787
def update_event(self, event, uid):
        
        ev_for_change = self.calendar.get(uid)
        ev_for_change.content = event
        ev_for_change.save()
465156
public PeriodicEvent runAfter(Runnable task, float delay) {
        validateDelay(delay);
        return new Event(task, delay);
    }
90092
def _schedule(self):
        ''''''
        if self._running:
            _logger.debug('')
            self._call_later_handle = self._event_loop.call_later(
                self._timeout, self._check)
1180865
function run (task, runId)
{
	if (task._runId !== runId)
		return;
	
	var delay = Math.max(0, task.nextEvent.getTime() - Date.now());
	task._timeout = setTimeout(executeTask, delay, task, runId);
	if (task._unref)
		task._timeout.unref();
}
743553
def _update_events(self):
        """"""
        events = self._skybell.dev_cache(self, CONST.EVENT) or {}

        for activity in self._activities:
            event = activity.get(CONST.EVENT)
            created_at = activity.get(CONST.CREATED_AT)

            old_event = events.get(event)

            if old_event and created_at < old_event.get(CONST.CREATED_AT):
                continue
            else:
                events[event] = activity

        self._skybell.update_dev_cache(
            self,
            {
                CONST.EVENT: events
            })
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)
348830
def run_event_hooks(event, task):
    

    # get chain of classes registered for this event
    call_chain = _event_hooks.get(event)

    if call_chain:
        # lookup the associated class method for this event
        event_methods = {
            'task_start': 'on_taskstart',
            'task_run': 'on_taskrun',
            'task_end': 'on_taskend'
        }
        method = event_methods.get(event)

        if method:
            for _, get_plugin in call_chain:
                plugin_obj = get_plugin()

                if not _is_plugin_disabled(plugin_obj):
                    try:
                        getattr(plugin_obj, method)(task)  # execute
                    except Exception:
                        # TODO: log these issues for plugin author or user
                        pass
151975
def run(*tasks: Awaitable, loop: asyncio.AbstractEventLoop=asyncio.get_event_loop()):
    
    futures = [asyncio.ensure_future(task, loop=loop) for task in tasks]
    return loop.run_until_complete(asyncio.gather(*futures))
277716
def run(self):
    """"""
    while not self._state.is_terminating:
      self._process_event_queue()
      self._state.maybe_pause()
918081
def run(self):
        
        listener = EventServer(self.address, EventNotifyHandler)
        log.info("Event listener running on %s", listener.server_address)
        # Listen for events until told to stop
        while not self.stop_flag.is_set():
            listener.handle_request()
261863
def run(self):
        """"""
        (task_id, tasks) = self.server.get_task()
        self.task_store.from_dict(tasks)
        for (index, task) in self.task_store:
            result = self.compute(index, task)
            self.results.append(result)
        self.server.task_done((task_id, self.results))
1372087
void refresh() {
		if (isCompleted()) {
			return;
		}

		if (hProcess.getCompleted().contains(plugin)) {
			status = STATUS_COMPLETED;
		} else if (hProcess.getRunning().contains(plugin)) {
			status = STATUS_RUNNING;
		}
	}
148032
def _run_events(self, shutdown=False):
        

        # run task_start events, if not ran already
        if not self._ran_taskstart:
            self._ran_taskstart = True
            registration.run_event_hooks('task_start', self._task)

        # run events
        event = 'task_end' if shutdown else 'task_run'
        registration.run_event_hooks(event, self._task)

        # reclaim any subprocesses plugins may have forked
        try:
            os.waitpid(-1, os.P_NOWAIT)
        except OSError:
            pass
699804
def run(self, target, args=()):
        
        run_event = threading.Event()
        run_event.set()
        thread = threading.Thread(target=target, args=args + (run_event, ))
        self.thread_pool.append(thread)
        self.run_events.append(run_event)
        thread.start()