Adds an arg and gets back a future.

    Args:
      arg: one argument for _todo_tasklet.
      options: rpc options.

    Return:
      An instance of future, representing the result of running
        _todo_tasklet without batching.
771867
def add(self, arg, options=None):
    
    fut = tasklets.Future('%s.add(%s, %s)' % (self, arg, options))
    todo = self._queues.get(options)
    if todo is None:
      utils.logging_debug('AutoBatcher(%s): creating new queue for %r',
                          self._todo_tasklet.__name__, options)
      if not self._queues:
        eventloop.add_idle(self._on_idle)
      todo = self._queues[options] = []
    todo.append((fut, arg))
    if len(todo) >= self._limit:
      del self._queues[options]
      self.run_queue(options, todo)
    return fut
485485
def args(self, *args, **kwargs):
        
        self._any_args = False
        self._arguments_rule.set_args(*args, **kwargs)
        return self
1183700
def submit(self, call, *args, **kwargs):
        
        future = StoredFuture(call, *args, **kwargs)
        self._queue.put(future)
        self._ensure_worker()
        return future
357817
def tailing_non_options
      args = []

      # add all tailing subtask non-options
      @subtasks.each_value do |task|
        args += task.tailing_non_options
      end

      # add the task tailing non-options
      @options.each do |name,value|
        non_opt = get_non_option(name)

        if (non_opt && non_opt.tailing?)
          args += non_opt.arguments(value)
        end
      end

      return args
    end
647991
def add(self, target, args=None, kwargs=None, **options):
        

        # In superclass, add new task to our list of tasks
        target = super(
            AutoContext, self).add(target, args, kwargs, **options)

        self._auto_insert_check()

        return target
561312
def put(self, task, args, kwargs):
        
        if self.num_threads == 0:
            return task(*args, **kwargs)
        if self.queue is None:
            self._spawn()
        self.queue.put((task, args, kwargs))
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
56781
def send(self, task_path, args, kwargs):
        
        message = {
                'task_path': task_path,
                'capture_response': self.capture_response,
                'response_id': self.response_id,
                'args': args,
                'kwargs': kwargs
            }
        self._send(message)
        return self
1281691
def AddArg(self, arg):
    
    self.args.append(arg)
    if len(self.args) > self.number_of_args:
      raise ParseError("Too many args for this expression.")

    elif len(self.args) == self.number_of_args:
      return True

    return False
1217593
def bind(self, __fun, *args, **kwargs):
    

    with self._lock:
      if self._running or self._completed or self._cancelled:
        raise RuntimeError('Future object can not be reused')
      if self._worker:
        raise RuntimeError('Future object is already bound')
      self._worker = functools.partial(__fun, *args, **kwargs)
    return self
21064
def return_future(fn):
    
    @wraps(fn)
    def decorated(*args, **kwargs):
        return gen.maybe_future(fn(*args, **kwargs))

    return decorated
273247
def _invoke(task, args):
	''''''
	kwargs = task.defaults.copy()
	if task.kwargs:
		temp_kwargs, args = getopt.getopt(args, '', task.kwargs)
		temp_kwargs = _opts_to_dict(*temp_kwargs)
		kwargs.update(temp_kwargs)

	if task.args:
		for arg in task.args:
			if not len(args):
				abort(LOCALE['error_wrong_args'], task, len(task.args))
			kwargs.update({arg: args[0]})
			args = args[1:]

	if task.consume:
		task(*args, **kwargs)
		return []
	else:
		task(**kwargs)
		return args
1053973
def start_thread(self, target, args=(), kwargs=None, priority=0):
        
        return self.add_task(target, args, kwargs, priority)
672271
def apply_async(self, args=None, kwargs=None, **options):  # pylint: disable=arguments-differ
        
        result = super(LoggedTask, self).apply_async(args=args, kwargs=kwargs, **options)
        log.info('Task {}[{}] submitted with arguments {}, {}'.format(
            self.name,
            result.id,
            args,
            kwargs
        ))
        return result
588155
def _add_argument(obj, arg):
        
        argparse_options = {name: value for name, value in arg.options.items() if name in ARGPARSE_SUPPORTED_KWARGS}
        if arg.options_list:
            scrubbed_options_list = []
            for item in arg.options_list:

                if isinstance(item, Deprecated):
                    # don't add expired options to the parser
                    if item.expired():
                        continue

                    class _DeprecatedOption(str):
                        def __new__(cls, *args, **kwargs):
                            instance = str.__new__(cls, *args, **kwargs)
                            return instance

                    option = _DeprecatedOption(item.target)
                    setattr(option, 'deprecate_info', item)
                    item = option
                scrubbed_options_list.append(item)
            return obj.add_argument(*scrubbed_options_list, **argparse_options)

        if 'required' in argparse_options:
            del argparse_options['required']
        if 'metavar' not in argparse_options:
            argparse_options['metavar'] = '<{}>'.format(argparse_options['dest'].upper())
        return obj.add_argument(**argparse_options)
1220056
def append(self, *args):
        
        self.args.append(args)
        if self.started:
            self.started = False
        return self.length()
991222
def middleware(self, *args, **kwargs):
        

        def register_middleware(_middleware):
            future_middleware = FutureMiddleware(_middleware, args, kwargs)
            self.middlewares.append(future_middleware)
            return _middleware

        # Detect which way this was called, @middleware or @middleware('AT')
        if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
            middleware = args[0]
            args = []
            return register_middleware(middleware)
        else:
            if kwargs.get("bp_group") and callable(args[0]):
                middleware = args[0]
                args = args[1:]
                kwargs.pop("bp_group")
                return register_middleware(middleware)
            else:
                return register_middleware