Check if there are changes, if true, run the given task.
553129
def examine(self):
        """"""
        if self._changes:
            return self._changes.pop()

        # clean filepath
        self.filepath = None
        delays = set([0])
        for path in self._tasks:
            item = self._tasks[path]
            if self.is_changed(path, item['ignore']):
                func = item['func']
                func and func()
                delay = item['delay']
                if delay:
                    delays.add(delay)

        if 'forever' in delays:
            delay = 'forever'
        else:
            delay = max(delays)
        return self.filepath, delay
989050
def _update(self):
        """"""
        update = False

        with self._lock:
            for fname in ['pending.data', 'completed.data']:
                data_file = join(self._data_location, fname)
                if exists(data_file):
                    mtime = getmtime(data_file)
                    if mtime > self._mtime:
                        self._mtime = mtime
                        update = True

            if update:
                self._tasks = {}
                tasklist = loads(run(['task', 'rc.verbose=nothing', 'rc.hooks=off', 'rc.data.location={self._data_location}'.format(**locals()), 'export'], stdout=PIPE).stdout.decode('utf-8'))
                for task in tasklist:
                    project = task['project'] if 'project' in task else 'unaffiliated'
                    if project not in self._tasks:
                        self._tasks[project] = {}
                    self._tasks[project][task['uuid']] = task
19060
def do(self, changes, task_handle=taskhandle.NullTaskHandle()):
        
        try:
            self.current_change = changes
            changes.do(change.create_job_set(task_handle, changes))
        finally:
            self.current_change = None
        if self._is_change_interesting(changes):
            self.undo_list.append(changes)
            self._remove_extra_items()
        del self.redo_list[:]
82729
def task_done(self, **kw):
        
        def validate(task):
            if not Status.is_pending(task['status']):
                raise ValueError("Task is not pending.")

        return self._task_change_status(Status.COMPLETED, validate, **kw)
66446
def run_recursively_and_collect_multiple_changes(monitor, times, directory, *flags, &block)
      watch_and_run(monitor, times, true, directory, *flags, &block)
    end
881256
def run(self, change):
        

        if self._formats is None:
            self.setup()

        entry = self.entry

        for fmt in self._formats:
            fmt.run(change, entry)

        self.clear()
906454
def _run_checks(self):
        '''
        '''
        if self.recipe is not None:

            # Does the recipe provided exist?
            if not os.path.exists(self.recipe):
                bot.error("Cannot find %s, is the path correct?" %self.recipe)
                sys.exit(1)

            # Ensure we carry fullpath
            self.recipe = os.path.abspath(self.recipe)
1167716
def run_check(self, check, argument_names):
        """"""
        arguments = []
        for name in argument_names:
            arguments.append(getattr(self, name))
        return check(*arguments)
865573
public static void call(Runnable task) {
        try {
            call(() -> {
                task.run();
                return true;
            });
        } catch (Exception e) {
            // It's safe to throw unsafely here because the Callable we passed never throws a checked exception.
            Exceptions.throwUnsafely(e);
        }
    }
1204675
def run_on_changes(paths)
      specs = Inspector.clean(paths)
      return false if specs.empty?

      specs += self.rerun_specs if options[:keep_failed]

      # RSpec reloads the files, so reload only non spec files
      (paths - specs).each { |path| Reloader.reload_file(path) }

      passed, failed_examples, passed_examples = Runner.run(specs, options)

      self.rerun_specs += failed_examples
      self.rerun_specs -= passed_examples

      run_all if passed && !self.last_run_passed && options[:all_after_pass]

      self.last_run_passed = passed

      throw :task_has_failed unless passed
    end
1094843
def run_check(self, template_name=None, service_dir=None):
        "  "

        print_header('Check requirements', sep='-')
        map(lambda cmd: call("bash %s" % cmd), self._gen_scripts(
            'check', template_name=template_name, service_dir=service_dir))
        return True
373778
def if_running(meth):
        """"""

        @wraps(meth)
        def check_running(self, *args, **kwargs):
            if not self.running:
                return
            return meth(self, *args, **kwargs)

        return check_running
41620
def execute(self, env, args):
        

        # extract args
        old_task_name = args.old_task_name
        new_task_name = args.new_task_name

        if old_task_name == new_task_name:
            raise errors.FocusError(u'Could not rename task to itself')

        if env.task.active and env.task.name == old_task_name:
            raise errors.ActiveTask

        env.task.rename(old_task_name, new_task_name)
439779
def _run_task(self, play, task, is_handler):
        '''   '''

        self.callbacks.on_task_start(utils.template(play.basedir, task.name, task.module_vars, lookup_fatal=False), is_handler)

        # load up an appropriate ansible runner to run the task in parallel
        results = self._run_task_internal(task)

        # if no hosts are matched, carry on
        hosts_remaining = True
        if results is None:
            hosts_remaining = False
            results = {}
 
        contacted = results.get('contacted', {})
        self.stats.compute(results, ignore_errors=task.ignore_errors)

        # add facts to the global setup cache
        for host, result in contacted.iteritems():
            # Skip register variable if host is skipped
            if result.get('skipped', False):
                continue
            facts = result.get('ansible_facts', {})
            self.SETUP_CACHE[host].update(facts)
            # extra vars need to always trump - so update  again following the facts
            self.SETUP_CACHE[host].update(self.extra_vars)
            if task.register:
                if 'stdout' in result:
                    result['stdout_lines'] = result['stdout'].splitlines()
                self.SETUP_CACHE[host][task.register] = result

        # flag which notify handlers need to be run
        if len(task.notify) > 0:
            for host, results in results.get('contacted',{}).iteritems():
                if results.get('changed', False):
                    for handler_name in task.notify:
                        self._flag_handler(play, utils.template(play.basedir, handler_name, task.module_vars), host)

        return hosts_remaining
210224
def reload
            server_success = server.reload(options)
            runner_success = runner.reload(options)
            throw :task_has_failed unless server_success && runner_success
        end
796009
def run_program(program, *args):
    """"""
    real_args = [program]
    real_args.extend(args)
    logging.debug(_('check_output arguments: %s'), real_args)
    check_output(real_args, universal_newlines=True)
619906
void runAsync() {
        // Determine if a task is running. If so, record the fact we want to have it run again, otherwise reserve our spot.
        synchronized (this) {
            Exceptions.checkNotClosed(this.closed, this);
            if (this.running) {
                this.runAgain = true;
                return;
            }

            this.running = true;
        }

        // Execute the task.
        runInternal();
    }