Decorates a function with the db_mutex decorator by using this class as a context manager around
        it.
433249
def decorate_callable(self, func):
        
        def wrapper(*args, **kwargs):
            try:
                with self:
                    result = func(*args, **kwargs)
                return result
            except DBMutexError as e:
                if self.suppress_acquisition_exceptions:
                    LOG.error(e)
                else:
                    raise e
        functools.update_wrapper(wrapper, func)
        return wrapper
91771
def decorate_function(self, name, decorator):
        
        self.functions[name] = decorator(self.functions[name])
449087
def decorate(decorator_cls, *args, **kwargs):
    """"""
    global _wrappers

    wrapper_cls = _wrappers.get(decorator_cls, None)
    if wrapper_cls is None:

        class PythonWrapper(decorator_cls):
            pass

        wrapper_cls = PythonWrapper
        wrapper_cls.__name__ = decorator_cls.__name__ + "PythonWrapper"
        _wrappers[decorator_cls] = wrapper_cls

    def decorator(fn):
        wrapped = wrapper_cls(fn, *args, **kwargs)
        _update_wrapper(wrapped, fn)
        return wrapped

    return decorator
101441
def shell_context_processor(self, func: Callable) -> Callable:
        
        self.shell_context_processors.append(func)
        return func
129035
def define(self, klass, name="default"):
        

        def decorate(func):
            @wraps(func)
            def wrapped(*args, **kwargs):
                return func(*args, **kwargs)

            self.register(klass, func, name=name)

            return wrapped

        return decorate
1340569
def _Function(self, t):
        
        if t.decorators is not None:
            self._fill("@")
            self._dispatch(t.decorators)
        self._fill("def "+t.name + "(")
        defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults)
        for i, arg in enumerate(zip(t.argnames, defaults)):
            self._write(arg[0])
            if arg[1] is not None:
                self._write('=')
                self._dispatch(arg[1])
            if i < len(t.argnames)-1:
                self._write(', ')
        self._write(")")
        if self._single_func:
            self._do_indent = False
        self._enter()
        self._dispatch(t.code)
        self._leave()
        self._do_indent = True
1374675
def decorator(caller, _func=None):
    """"""
    if _func is not None:  # return a decorated function
        # this is obsolete behavior; you should use decorate instead
        return decorate(_func, caller)
    # else return a decorator function
    defaultargs, defaults = '', ()
    if inspect.isclass(caller):
        name = caller.__name__.lower()
        doc = 'decorator(%s) converts functions/generators into ' \
            'factories of %s objects' % (caller.__name__, caller.__name__)
    elif inspect.isfunction(caller):
        if caller.__name__ == '<lambda>':
            name = '_lambda_'
        else:
            name = caller.__name__
        doc = caller.__doc__
        nargs = caller.__code__.co_argcount
        ndefs = len(caller.__defaults__ or ())
        defaultargs = ', '.join(caller.__code__.co_varnames[nargs-ndefs:nargs])
        if defaultargs:
            defaultargs += ','
        defaults = caller.__defaults__
    else:  # assume caller is an object with a __call__ method
        name = caller.__class__.__name__.lower()
        doc = caller.__call__.__doc__
    evaldict = dict(_call=caller, _decorate_=decorate)
    dec = FunctionMaker.create(
        '%s(func, %s)' % (name, defaultargs),
        'if func is None: return lambda func:  _decorate_(func, _call, (%s))\n'
        'return _decorate_(func, _call, (%s))' % (defaultargs, defaultargs),
        evaldict, doc=doc, module=caller.__module__, __wrapped__=caller)
    if defaults:
        dec.__defaults__ = (None,) + defaults
    return dec
1021523
def threaded(func):
    

    def dec(self, *args, **kwargs):
        thread.start_new_thread(func, (self, ) + args, kwargs)

    return dec
248294
def operations():
    
    def decorator(func):
        @wraps(func)
        def wrapped_func(*args, **kwargs):

            self = args[0]
            assert self.__can_use, "User operation queue only in 'with' block"

            def defaults_dict():
                f_args, varargs, keywords, defaults = inspect.getargspec(func)
                defaults = defaults or []
                return dict(zip(f_args[-len(defaults)+len(args[1:]):], defaults[len(args[1:]):]))

            route_args = dict(defaults_dict().items() + kwargs.items())

            func(*args, **kwargs)
            self.operations.append((func.__name__, args[1:], route_args, ))

        return wrapped_func
    def decorate(clazz):

        for attr in clazz.__dict__:
            if callable(getattr(clazz, attr)):
                setattr(clazz, attr, decorator(getattr(clazz, attr)))
        def __init__(self):  # simple parameter-less constructor
            self.operations = []
            self.__can_use = True
        def invalidate(self):
            self.__can_use = False
        clazz.__init__ = __init__
        clazz.invalidate = invalidate
        return clazz
    return decorate
636863
def _make_function(instr, queue, stack, body, context):
    
    assert stack, "Empty stack before MAKE_FUNCTION."
    prev = stack[-1]
    expect(prev, instrs.LOAD_CONST, "before MAKE_FUNCTION")

    stack.append(instr)

    if is_lambda_name(prev.arg):
        return

    return context.update(
        make_function_context=MakeFunctionContext(
            closure=isinstance(instr, instrs.MAKE_CLOSURE),
        )
    )
82355
def memoized(func):
    
    cache = {}
    @wraps(func)
    def memoized_function(*args):
        """The decorated function.
        """
        try:
            return cache[args]
        except KeyError:
            value = func(*args)
            try:
                cache[args] = value
            except MemoryError:
                cache.clear()
                gc.collect()
            return value
    return memoized_function
936716
def callwith(context_manager):
    
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwds):
            with context_manager:
                return func(*args, **kwds)
        return wrapper
    return decorator
509758
@Beta
    public static <T, U, R> BiFunction<T, U, R> sf(final Object mutex, final BiFunction<T, U, R> biFunction) {
        N.checkArgNotNull(mutex, "mutex");
        N.checkArgNotNull(biFunction, "biFunction");

        return new BiFunction<T, U, R>() {
            @Override
            public R apply(T t, U u) {
                synchronized (mutex) {
                    return biFunction.apply(t, u);
                }
            }
        };
    }
130991
def inject(*injections):
    ''''''
    def _decorate(func):
        def _decorated(*args, **kwargs):
            args = list(args)
            keys_to_inject = [name for name in injections if name not in kwargs]
            for key in keys_to_inject:
                kwargs[key] = get_current_scope().container.get(key)
            return func(*args, **kwargs)
        return _decorated
    return _decorate
111526
def _wrap(cls, func):
        

        if isinstance(func, cls):
            return func
        return functools.update_wrapper(cls(func), func)
1173079
def _hook_decorator(self, addr, length=0, kwargs=None):
        

        def hook_decorator(func):
            self.hook(addr, func, length=length, kwargs=kwargs)
            return func

        return hook_decorator
500108
function decorateMethodDoc(methodDoc) {
    normalizeMethodParameters(methodDoc);

    // Mark methods with a `void` return type so we can omit show the return type in the docs.
    methodDoc.showReturns = methodDoc.returnType && methodDoc.returnType != 'void';
  }