Runs each function from ``self.before_first_request_funcs`` once and only once.
194079
def _try_trigger_before_first_request_funcs(self):  # pylint: disable=C0103
        """"""
        if self._after_first_request_handled:
            return
        else:
            with self._before_first_request_lock:
                if self._after_first_request_handled:
                    return
                for func in self._before_first_request_funcs:
                    func()
                self._after_first_request_handled = True
656436
def run_once_on_threshold(callback, mv_lower, mv_upper, mv_reset=10, interval=0.01)
      AIN::run_once_on_threshold(callback, @pin, mv_lower, mv_upper, mv_reset, interval)
    end
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
1088624
function(options){
    this.triggerMethod("initialize:before", options);
    this._initCallbacks.run(options, this);
    this.triggerMethod("initialize:after", options);

    this.triggerMethod("start", options);
  }
19130
function once(fn) {
  var called, value;

  if (typeof fn !== 'function') {
    throw new Error('expected a function but got ' + fn);
  }

  return function wrap() {
    if (called) {
      return value;
    }
    called = true;
    value = fn.apply(this, arguments);
    fn = undefined;
    return value;
  };
}
1020653
function runAfterDetach (args, methodMeta, ret) {
    // skip if no afterDetach methods
    if (!defined(methodMeta.afterDetach)) {
        return
    }
    // wait for original promise to resolve then run detached after functions
    ret.then(res => {
        // build arguments for after methods
        args = {
            args: args.args ? args.args : args,
            res: res,
            origRes: args.origRes ? args.origRes : args.res,
            session: args.session,
        }
        // run all functions
        _.each(methodMeta.afterDetach, method => {
            // call method
            (method)(args, methodMeta.signature, 'afterDetach')
            // log errors
            .catch(err => {
                // require log client
                if (!defined(methodMeta.logClient)) {
                    return
                }
                // log error
                methodMeta.logClient.error(err, args.session)
            })
        })
    })
}
66525
function onetime() {
        if (called) return value;

        called = 1;
        value = fn.apply(this, arguments);
        fn = null;

        return value;
      }
927625
function (initFunction) {
        if (_.isFunction(initFunction)) {
            Logger.info("Run init function");
            _customInitFuncton = initFunction;
            return initFunction(appHttp)
                .then(function () {
                    return initFunction(appHttps);
                });
        }
        return Q();
    }
1117098
def run_once(f):
    ''' 
    
    '''
    def wrapper(*args, **kwargs):
        if not wrapper.has_run:
            wrapper.result = f(*args, **kwargs)
            wrapper.has_run = True
        return wrapper.result
    wrapper.has_run = False
    return wrapper
73782
function (events, func) {
    for (var i = 0; i < events.length; i++) {
      obj.once(events[i], func)
      listeners[events[i]] = func
    }
  }
1305862
def run_func(entry):
    """"""
    if entry.func:
        if entry.args and entry.krgs:
            return entry.func(*entry.args, **entry.krgs)
        if entry.args:
            return entry.func(*entry.args)
        if entry.krgs:
            return entry.func(**entry.krgs)
        return entry.func()
792415
def meth_once(f):
  ""
  attr = '__meth_once_'+f.__name__
  @functools.wraps(f)
  def f2(self,*args,**kwargs):
    if hasattr(self,attr): raise CallOnceError(f.__name__)
    setattr(self,attr,True)
    return f(self,*args,**kwargs)
  return f2
1217199
def _run_once(runner_list, extra_tick, use_poll):
    
    if len(runner_list) > 0:
        asyncore.loop(0, use_poll, None, 1)
        for runner in runner_list:
            if not runner.tick():
                return runner
    if extra_tick is not None:
        code = extra_tick()
        if code is False:
            return False
    return True
649226
def _multiple_callbacks(callbacks, *args, **kwargs):
    
    if isinstance(callbacks, list):
        for cb in callbacks:
            cb(*args, **kwargs)
        return
    if callbacks:
        callbacks(*args, **kwargs)
550896
def call_once(func):
  
  argspec = inspect.getargspec(func)
  if argspec.args or argspec.varargs or argspec.keywords:
    raise ValueError('Can only decorate functions with no args', func, argspec)

  @functools.wraps(func)
  def _wrapper():
    # If we haven't been called yet, actually invoke func and save the result.
    if not _wrapper.HasRun():
      _wrapper.MarkAsRun()
      _wrapper.return_value = func()
    return _wrapper.return_value

  _wrapper.has_run = False
  _wrapper.HasRun = lambda: _wrapper.has_run
  _wrapper.MarkAsRun = lambda: setattr(_wrapper, 'has_run', True)
  return _wrapper
1363624
def once(func):
    """"""
    lock = threading.Lock()

    def new_func(*args, **kwargs):
        if new_func.called:
            return
        with lock:
            if new_func.called:
                return
            rv = func(*args, **kwargs)
            new_func.called = True
            return rv

    new_func = update_wrapper(new_func, func)
    new_func.called = False
    return new_func
662534
def before_first_request(self, fn):
        
        self._defer(lambda app: app.before_first_request(fn))
        return fn