Decorator for registering a check to run every `every` (cronspec)
358368
def check_every(kls, every):
        """"""
        def wrapper(func):
            func.dashmat_check = Checker(func, every)
            return func
        return wrapper
1068301
function every(seq, pred, ctx) {
        return sequencep(seq)?  __every.call(seq, pred, ctx)
             : /* non-seq */    false
    }
91569
def call_repeatedly(func, interval, *args, **kwargs):
    
    main_thead = threading.current_thread()
    stopped = threading.Event()

    def loop():
        while not stopped.wait(interval) and main_thead.is_alive():  # the first call is in `interval` secs
            func(*args, **kwargs)

        return

    timer_thread = threading.Thread(target=loop, daemon=True)
    timer_thread.start()

    atexit.register(stopped.set)

    return timer_thread, stopped.set
966022
def start_executing_host_checks(self):
        
        # todo: #783 create a dedicated brok for global parameters
        if not self.my_conf.execute_host_checks:
            self.my_conf.modified_attributes |= DICT_MODATTR["MODATTR_ACTIVE_CHECKS_ENABLED"].value
            self.my_conf.execute_host_checks = True
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
1356865
def callable_check(func, arg_count=1, arg_value=None, allow_none=False):
        """"""
        if func is None:
            if not allow_none:
                raise ValueError('callable cannot be None')
        elif not arg_checker(func, *[arg_value for _ in range(arg_count)]):
            raise ValueError('callable %s invalid (for %d arguments)' % (func, arg_count))
737470
def check_wrapper(fun):
    ''''''
    @wraps(fun)
    def _wrapper(*args, **kwargs):
        '''Sets the title property of the result of running a checker'''
        title = fun.__name__.replace('_', ' ').capitalize()
        result = fun(*args, **kwargs)
        result.title = title
        return result

    return _wrapper
511882
def all(self, func=None):
        
        if func is None:
            func = lambda x, *args: x
        self.altmp = True

        def testEach(value, index, *args):
            if func(value, index, *args) is False:
                self.altmp = False

        self._clean.each(testEach)
        return self._wrap(self.altmp)
277480
def run_once(self):
        ''''''

        self._update_projects()
        self._check_task_done()
        self._check_request()
        while self._check_cronjob():
            pass
        self._check_select()
        self._check_delete()
        self._try_dump_cnt()
321904
def _make_matchers(self, crontab):
        '''
        
        '''
        crontab = _aliases.get(crontab, crontab)
        ct = crontab.split()
        if len(ct) == 5:
            ct.insert(0, '0')
            ct.append('*')
        elif len(ct) == 6:
            ct.insert(0, '0')
        _assert(len(ct) == 7,
            "improper number of cron entries specified; got %i need 5 to 7"%(len(ct,)))

        matchers = [_Matcher(which, entry) for which, entry in enumerate(ct)]

        return Matcher(*matchers)
713840
def run_once(function, state={}, errors={}):
    """"""
    @six.wraps(function)
    def _wrapper(*args, **kwargs):
        if function in errors:
            # Deliberate use of LBYL.
            six.reraise(*errors[function])

        try:
            return state[function]
        except KeyError:
            try:
                state[function] = result = function(*args, **kwargs)
                return result
            except Exception:
                errors[function] = sys.exc_info()
                raise
    return _wrapper
816280
def run_cron_with_cache_check(cron_class, force=False, silent=False):
    

    with CronJobManager(cron_class, silent) as manager:
        manager.run(force)
255838
def _mod_run_check(cmd_kwargs, onlyif, unless):
    '''
    
    '''
    if onlyif:
        if __salt__['cmd.retcode'](onlyif, **cmd_kwargs) != 0:
            return {'comment': 'onlyif condition is false',
                    'skip_watch': True,
                    'result': True}

    if unless:
        if __salt__['cmd.retcode'](unless, **cmd_kwargs) == 0:
            return {'comment': 'unless condition is true',
                    'skip_watch': True,
                    'result': True}

    # No reason to stop, return True
    return True
320167
def determine_check_cron_time(check)
      cron_parser = CronParser.new(check[:cron])
      current_time = Time.now
      next_cron_time = cron_parser.next(current_time)
      next_cron_time - current_time
    end
1187031
function(callback){
              [].every.call(this, function(el, idx){
                return callback.call(el, idx, el) !== false
              })
              return this
            }
804091
def check(*args, **kwds):
  
  def wrapper(checkfunc):
    return wraps(checkfunc)(FontBakeryCheck(checkfunc, *args, **kwds))
  return wrapper
1364824
function Cron (pattern, options, fn) {
		var self = this;
		
		// Optional "new" keyword
		if( !(this instanceof Cron) ) {
			return new Cron(pattern, options, fn);
		}

		self.pattern = new CronPattern(pattern);

		self.schedulerDefaults = {
			stopAt:     Infinity,
			maxRuns:    Infinity,
			kill:       false
		};

		// Make options optional
		if( typeof options === "function" ) {
			fn = options;
			options = {};
		}

		// Store and validate options
		self.opts = self.validateOpts(options || {});

		// Determine what to return, default is self
		if( fn === void 0 ) {
			// Normal initialization, return self
			return self;

		} else {
			// Shorthand schedule requested, return job
			return this.schedule(options, fn);

		}

	}
1265810
def register(name, _callable=None):
    
    def wrapper(_callable):
        registered_checks[name] = _callable
        return _callable

    # If function or class is given, do the registeration
    if _callable:
        return wrapper(_callable)

    return wrapper