Convert SerializedFunction objects to function, so when called
we execute the function in the original thread
196874
function ConvertArgs(args, baseResponse) {
    var baseResponse = Object.assign({}, baseResponse);
    args.forEach(function(arg, i) {
        if (typeof(arg) == "object" && arg._classname == "SerializedFunction") {
            var idRemoteFunction = arg.id;
            args[i] = function() {
                process.send(Object.assign(baseResponse, {name: "thread-execute-remote-function", args: [{id: idRemoteFunction, args: SerializeForProcess(CopyArguments(arguments))}]}));
            };
        }
    });
    return args;
}
576306
def extern_call(self, context_handle, func, args_ptr, args_len):
    """"""
    c = self._ffi.from_handle(context_handle)
    runnable = c.from_value(func[0])
    args = tuple(c.from_value(arg[0]) for arg in self._ffi.unpack(args_ptr, args_len))
    return self.call(c, runnable, args)
1078598
def synchronized(fn):
    '''
    
    '''
    lock = threading.Lock()

    @functools.wraps(fn)
    def decorated(*args, **kwargs):
        lock.acquire()
        try:
            return fn(*args, **kwargs)
        finally:
            lock.release()

    return decorated
1130338
def fmap(self, f: 'WrappedFunction') -> 'WrappedFunction':
        '''
            
        '''
        if not isinstance(f, WrappedFunction):
            f = WrappedFunction(f)
        return WrappedFunction(lambda *args, **kwargs: self(f(*args, **kwargs)), nargs=f.nargs, nouts=self.nouts)
784187
def synchronized(lock):
    
    @simple_decorator
    def wrap(function_target):
        """Decorator wrapper"""
        def new_function(*args, **kw):
            """Decorated function with Mutex"""
            lock.acquire()
            try:
                return function_target(*args, **kw)
            finally:
                lock.release()
        return new_function
    return wrap
216187
def foreachRDD(self, func):
        
        if func.__code__.co_argcount == 1:
            old_func = func
            func = lambda t, rdd: old_func(rdd)
        jfunc = TransformFunction(self._sc, func, self._jrdd_deserializer)
        api = self._ssc._jvm.PythonDStream
        api.callForeachRDD(self._jdstream, jfunc)
770129
def run_on_new_thread(func, daemon=True):
    
    f = concurrent.futures.Future()
    def wrapper():
        if not f.set_running_or_notify_cancel():
            return
        try:
            f.set_result(func())
        except Exception as e:
            f.set_exception(e)
    t = threading.Thread(target=wrapper)
    t.daemon = daemon
    t.start()
    return f
1222386
def _execute_if_not_empty(func):
    
    def wrapper(*args, **kwargs):
        if any(args[1:]) or any(kwargs.items()):
            return func(*args, **kwargs)
    return wrapper
1295519
public static void convert(Task task, Function<Throwable, RuntimeException> function) {
        try {
            task.run();
        } catch (Throwable e) {
            throw function.apply(e);
        }
    }
630132
def pass_obj(f):
    
    def new_func(*args, **kwargs):
        return f(get_current_context().obj, *args, **kwargs)
    return update_wrapper(new_func, f)
753740
def _onFunction(self, name, line, pos, absPosition,
                    keywordLine, keywordPos,
                    colonLine, colonPos, level,
                    isAsync, returnAnnotation):
        """"""
        self.__flushLevel(level)
        f = Function(name, line, pos, absPosition, keywordLine, keywordPos,
                     colonLine, colonPos, isAsync, returnAnnotation)
        if self.__lastDecorators is not None:
            f.decorators = self.__lastDecorators
            self.__lastDecorators = None
        self.objectsStack.append(f)
1029676
def action(source, func):
    
    if asyncio.iscoroutinefunction(func):
        async def innerfunc(arg):
            await func(arg)
            return arg
    else:
        def innerfunc(arg):
            func(arg)
            return arg
    return map.raw(source, innerfunc)
1356875
def threaded(system, func, *args, **kwargs):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except Exception as e:
            if system.raven_client:
                system.raven_client.captureException()
            logger.exception('Exception occurred in thread: %s', e)
            return False

    return lambda: wrapper(*args, **kwargs)
1284002
private List<Type> executeCall(
            Function function) throws IOException {
        String encodedFunction = FunctionEncoder.encode(function);
        org.web3j.protocol.core.methods.response.EthCall ethCall = web3j.ethCall(
                Transaction.createEthCallTransaction(
                        transactionManager.getFromAddress(), contractAddress, encodedFunction),
                defaultBlockParameter)
                .send();

        String value = ethCall.getValue();
        return FunctionReturnDecoder.decode(value, function.getOutputParameters());
    }
1208690
function () {
            /*  if context is an object, annotate it with
                the real "this" pointer of this method call  */
            if (_cs.istypeof(arguments.callee.__ctx__) === "object")
                arguments.callee.__ctx__.__this__ = this;

            /*  just pass execution through to wrapped function
                with our attached store as its execution context object  */
            return func.apply(arguments.callee.__ctx__, arguments);
        }
882765
public <T> Observable<T> execute(ResultSetMapper<? extends T> function) {
        return bufferedParameters(this)
                // execute once per set of parameters
                .concatMap(executeOnce(function));
    }
1076565
def firethread(f):
    '''
    
    '''

    @functools.wraps(f)
    def callmeth(*args, **kwargs):
        thr = worker(f, *args, **kwargs)
        return thr

    return callmeth