Return a value of 'async' in kwargs or default when async_ is None.

    This helper function exists for backward compatibility (See #274).
    It shows a warning message when 'async' in kwargs is used to note users.
13262
def check_async(async_, kwargs, default):
    
    if async_ is not None:
        return async_
    elif 'async' in kwargs:
        warnings.warn(
            '"async" attribute is deprecated. Use "async_" instead.',
            DeprecationWarning,
        )
        return kwargs.pop('async')
    else:
        return default
483924
def get_default_value(self, check):
        
        fun_name, fun_args, fun_kwargs, default = self._parse_with_caching(check)
        if default is None:
            raise KeyError('Check "%s" has no default value.' % check)
        value = self._handle_none(default)
        if value is None:
            return value
        return self._check_value(value, fun_name, fun_args, fun_kwargs)
335459
def async_call(func, *args, callback=None):
    '''
    '''
    def do_call():
        result = None
        error = None

        try:
            result = func(*args)
        except Exception:
            error = traceback.format_exc()
            logger.error(error)
        if callback:
            GLib.idle_add(callback, result, error)

    thread = threading.Thread(target=do_call)
    thread.daemon = True
    thread.start()
245554
def call(self, func, *args, **kwargs):
        
        t0 = time.time()
        try:
            recv = self.call_async(func, *args, **kwargs)
            return self._rethrow(recv)
        finally:
            LOG.debug('Call took %d ms: %r', 1000 * (time.time() - t0),
                      mitogen.parent.CallSpec(func, args, kwargs))
603775
def return_value(self, *args, **kwargs):
        

        self._called()
        return self._return_value(*args, **kwargs)
1370340
def apply_async(self, args=None, kwargs=None, **options):
        
        if self.is_previous_task_processing(*args, **kwargs):
            message = 'Background task %s was not scheduled, because its predecessor is not completed yet.' % self.name
            logger.info(message)
            # It is expected by Celery that apply_async return AsyncResult, otherwise celerybeat dies
            return self.AsyncResult(options.get('task_id') or str(uuid4()))
        return super(BackgroundTask, self).apply_async(args=args, kwargs=kwargs, **options)
827105
def get_old_value(
        self, args: Sequence[Any], kwargs: Dict[str, Any], default: Any = None
    ) -> Any:
        
        if self.arg_pos is not None and len(args) > self.arg_pos:
            return args[self.arg_pos]
        else:
            return kwargs.get(self.name, default)
689892
def submit(**kwargs):
    
    if 'alert' not in kwargs:
        raise ValueError('Alert required')

    if 'value' not in kwargs:
        raise ValueError('Value required')

    alert = kwargs.pop('alert')
    value = kwargs['value']

    if alert(value):
        fail(kwargs)
    else:
        ok(kwargs)
366647
def get_cached_value(self, *args, **kwargs):
        
        key = self.get_cache_key(*args, **kwargs)
        logger.debug(key)
        return self.cache.get(key, default=Ellipsis)
152728
def get_key(self, args=None, kwargs=None):
        
        restrict_to = self.once.get('keys', None)
        args = args or {}
        kwargs = kwargs or {}
        call_args = getcallargs(
                getattr(self, '_orig_run', self.run), *args, **kwargs)
        # Remove the task instance from the kwargs. This only happens when the
        # task has the 'bind' attribute set to True. We remove it, as the task
        # has a memory pointer in its repr, that will change between the task
        # caller and the celery worker
        if isinstance(call_args.get('self'), Task):
            del call_args['self']
        key = queue_once_key(self.name, call_args, restrict_to)
        return key
510191
async def set(self, *args, **kwargs):
        '''
        
        '''
        return await _maybe_await(self.event.set(*args, **kwargs))
263896
def get_queue(name='default', default_timeout=None, is_async=None,
              autocommit=None, connection=None, queue_class=None, job_class=None, **kwargs):
    
    from .settings import QUEUES

    if kwargs.get('async') is not None:
        is_async = kwargs['async']
        warnings.warn('The `async` keyword is deprecated. Use `is_async` instead', DeprecationWarning)

    # If is_async is provided, use it, otherwise, get it from the configuration
    if is_async is None:
        is_async = QUEUES[name].get('ASYNC', True)
    # same for job_class
    job_class = get_job_class(job_class)

    if default_timeout is None:
        default_timeout = QUEUES[name].get('DEFAULT_TIMEOUT')
    if connection is None:
        connection = get_connection(name)
    queue_class = get_queue_class(QUEUES[name], queue_class)
    return queue_class(name, default_timeout=default_timeout,
                       connection=connection, is_async=is_async,
                       job_class=job_class, autocommit=autocommit, **kwargs)
124479
def call_func(self, fun, **kwargs):
        '''
        
        '''
        return self.low(fun, kwargs, print_event=kwargs.get('print_event', True), full_return=kwargs.get('full_return', False))
721818
def get(self, *args, **kwargs):
        
        args, kwargs = self.__process__(*args, **kwargs)
        return check_output(args, **kwargs)
922874
def locked_coroutine(f):
    
    @asyncio.coroutine
    def new_function(*args, **kwargs):

        # In the instance of the class we will store
        # a lock has an attribute.
        lock_var_name = "__" + f.__name__ + "_lock"
        if not hasattr(args[0], lock_var_name):
            setattr(args[0], lock_var_name, asyncio.Lock())

        with (yield from getattr(args[0], lock_var_name)):
            return (yield from f(*args, **kwargs))

    return new_function
563133
def default_value(self):
        
        if self.has_default:
            if hasattr(self.default, '__call__'):
                return self.default()
            else:
                return self.default
        else:
            raise Exception("No default value specified")
867568
def call(self, name: str, *args, **kwargs):
        ''''''
        if self._event_dispatcher is not None:
            self._event_dispatcher.notify(name, *args, **kwargs)

        if self._callbacks[name]:
            return self._callbacks[name](*args, **kwargs)
        else:
            raise HookDisconnected('No callback is connected.')