Call the wrapped function, and wait for the result in a blocking fashion

        Returns the result of the function call.

        :param args:
        :param kwargs:
        :return: result of function call
166486
def block(self, *args, **kwargs):
        
        LOG.debug(
            '%s on %s (awaitable %s async %s provider %s)',
            'blocking',
            self._func,
            self._is_awaitable,
            self._is_asyncio_provider,
            self._concurrency_provider
        )

        if self._deferable:
            raise RuntimeError('Already activated this call by deferring it')
        with self._lock:
            if not hasattr(self, '_result'):
                try:
                    self._result = (
                        self._concurrency_provider.run_until_complete(self.defer(*args, **kwargs))
                        if self._is_asyncio_provider else self._func(*args, **kwargs)
                    )
                except queue.Empty:
                    raise CloudTimeoutError("No data received after %.1f seconds." % kwargs.get("timeout", 0))
            self._blocked = True
        return self._result
1092768
def request_blocking(self, method, params):
        
        response = self._make_request(method, params)

        if "error" in response:
            raise ValueError(response["error"])

        return response['result']
1231930
def call(self, func, *args, **kwargs):
        
        guessed_kwargs = self._guess_kwargs(func)
        for key, val in guessed_kwargs.items():
            kwargs.setdefault(key, val)
        try:
            return func(*args, **kwargs)
        except TypeError as exc:
            msg = (
                "tried calling function %r but failed, probably "
                "because it takes arguments that cannot be resolved"
            ) % func
            raise DiayException(msg) from exc
255559
def with_lock(lock, func, *args, **kwargs):
    
    d = lock.acquire()

    def release_lock(result):
        deferred = lock.release()
        return deferred.addCallback(lambda x: result)

    def lock_acquired(lock):
        return defer.maybeDeferred(func, *args, **kwargs).addBoth(release_lock)

    d.addCallback(lock_acquired)
    return d
1064390
def submit(self, func, *args, **kwargs):
        
        with self._shutdown_lock:
            if self._shutdown:
                raise RuntimeError(
                    'cannot schedule new futures after shutdown')
            if self.in_green_worker:
                return wait(func(*args, **kwargs))
            else:
                future = create_future(self._loop)
                self._put((future, func, args, kwargs))
                return future
710898
def delay(self, wait, *args):
        

        def call_it():
            self.obj(*args)

        t = Timer((float(wait) / float(1000)), call_it)
        t.start()
        return self._wrap(self.obj)
35609
def _capture(self, args, kwargs):
        ''''''
        self.called = self.called + 1
        self.method_args.append(args)
        self.named_method_args.append(kwargs)
        self.never_called = False
916282
def prep(self, wait, args, env=None):
        
        self.pattern = wait
        self.env = env
        self.args = args

        # wait is a function, supersedes the default behavior
        if callable(wait):
            self.wait = lambda lines: wait()
692576
def synchronized(func, *args, **kwargs):
    
    if not (args and hasattr(args[0], '_lock')):
        return func(*args, **kwargs)
    with args[0]._lock: # pylint: disable=W0212
        return func(*args, **kwargs)
171403
def ensure_async(function_original):
    

    def wrapper(*args, **kwargs):
        try:
            result = function_original(*args, **kwargs)
            if isinstance(result, Deferred):
                return result
            d = Deferred()
            d.callback(result)
            return d
        except:
            return fail()

    return wrapper
388059
def gcall(func, *args, **kwargs):
    
    def idle():
        with gdk.lock:
            return bool(func(*args, **kwargs))
    return gobject.idle_add(idle)
291465
def call(func, args):
    
    assert hasattr(func, '__call__'), 'Cannot call func: {}'.format(
        func.__name__)
    raw_func = (
        func if isinstance(func, FunctionType) else func.__class__.__call__)
    hints = collections.defaultdict(lambda: Any, get_type_hints(raw_func))
    argspec = _getargspec(raw_func)
    named_args = {}
    varargs = ()
    for k, nk, v in _normalize(args):
        if nk == argspec.varargs:
            hints[nk] = Tuple[hints[nk], ...]
        elif nk not in argspec.args and argspec.varkw in hints:
            hints[nk] = hints[argspec.varkw]
        try:
            value = cast(hints[nk], v)
        except TypeError as e:
            _LOGGER.exception(e)
            six.raise_from(exc.InvalidCliValueError(k, v), e)
        if nk == argspec.varargs:
            varargs = value
        elif (nk in argspec.args or argspec.varkw) and (
                nk not in named_args or named_args[nk] is None):
            named_args[nk] = value
    return func(*varargs, **named_args)
1232981
def async_func(self, function):
        """"""

        @wraps(function)
        def wrapped(*args, **kwargs):
            return self.submit(function, *args, **kwargs)

        return wrapped
693212
def call_after(lag):
  
  def decorator(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
      wrapper.timer.cancel() # Debounce
      wrapper.timer = threading.Timer(lag, func, args=args, kwargs=kwargs)
      wrapper.timer.start()
    wrapper.timer = threading.Timer(0, lambda: None) # timer.cancel now exists
    return wrapper
  return decorator
1334597
def _run_in_reactor(self, function, _, args, kwargs):
        

        def runs_in_reactor(result, args, kwargs):
            d = maybeDeferred(function, *args, **kwargs)
            result._connect_deferred(d)

        result = EventualResult(None, self._reactor)
        self._registry.register(result)
        self._reactor.callFromThread(runs_in_reactor, result, args, kwargs)
        return result
440092
def callback(func):
    
    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        result = func(*args, **kwargs)
        if inspect.iscoroutine(result):
            aio_loop.create_task(result)

    return wrapped
488140
function(func, wait) {
        var self = this,
            timeout,
            // args, // right now there is no need for arguments
            // context, // and for context
            timestamp
            // result // and for result

        var later = function() {
            if (self._disposed) {
                clearTimeout(timeout)
                timeout = self = null
                return
            }

            var last = getTime() - timestamp

            if (last < wait && last >= 0) {
                timeout = setTimeout(later, wait - last)
            } else {
                timeout = null
                // result = func.apply(context, args)
                func()
                // context = args = null
            }
        }

        return function() {
            // context = this
            // args = arguments
            timestamp = getTime()

            if (!timeout) {
                timeout = setTimeout(later, wait)
            }

            // return result
        }
    }