Enqueue a task.

        Returns a `Task` object.
167227
async def put(self, data, ttl=None, ttr=None, delay=None):
        
        the_tuple = await self.queue.put(self, data, ttl=ttl, ttr=ttr, delay=delay)
        if the_tuple.rowcount:
            return Task.create_from_tuple(self, the_tuple)
887695
def to_task(self):
        """"""
        task_args = self.get_task_args()

        # check for name in task args
        name = task_args.get('name', MESSAGE_PROCESSOR_NAME)

        # if the countdown isn't in the task_args set it to the frequency
        if not 'countdown' in task_args:
            task_args['countdown'] = self.frequency

        task_args['name'] = "%s-%s-%s-%s" % (
            name, self.tag, self.current_batch, self.time_throttle)

        self.update_options(task_args=task_args)

        return super(MessageProcessor, self).to_task()
1216080
def enqueue_taskset(taskset)
      RRRSpec.redis.rpush(RRRSpec.make_key(key, 'worker_queue'), taskset.key)
    end
101440
def async_task(func, *args, **kwargs):
    """"""
    keywords = kwargs.copy()
    opt_keys = (
    'hook', 'group', 'save', 'sync', 'cached', 'ack_failure', 'iter_count', 'iter_cached', 'chain', 'broker')
    q_options = keywords.pop('q_options', {})
    # get an id
    tag = uuid()
    # build the task package
    task = {'id': tag[1],
            'name': keywords.pop('task_name', None) or q_options.pop('task_name', None) or tag[0],
            'func': func,
            'args': args}
    # push optionals
    for key in opt_keys:
        if q_options and key in q_options:
            task[key] = q_options[key]
        elif key in keywords:
            task[key] = keywords.pop(key)
    # don't serialize the broker
    broker = task.pop('broker', get_broker())
    # overrides
    if 'cached' not in task and Conf.CACHED:
        task['cached'] = Conf.CACHED
    if 'sync' not in task and Conf.SYNC:
        task['sync'] = Conf.SYNC
    if 'ack_failure' not in task and Conf.ACK_FAILURES:
        task['ack_failure'] = Conf.ACK_FAILURES
    # finalize
    task['kwargs'] = keywords
    task['started'] = timezone.now()
    # signal it
    pre_enqueue.send(sender="django_q", task=task)
    # sign it
    pack = SignedPackage.dumps(task)
    if task.get('sync', False):
        return _sync(pack)
    # push it
    enqueue_id = broker.enqueue(pack)
    logger.info('Enqueued {}'.format(enqueue_id))
    logger.debug('Pushed {}'.format(tag))
    return task['id']
794734
def taskit(func):
    
    class NewTask(Task):
        def work(self, *args, **kw):
            return func(*args, **kw)
    return NewTask()
81034
def task(self):
        
        # If we have no .task_id, this is a no-op to return None.
        if not self.task_id:
            return defer.succeed(None)
        return self.connection.getTaskInfo(self.task_id)
733899
def enqueue(taskset, recalculate = false)
      RRRSpec.redis.rpush(STATISTICS_UPDATER_QUEUE_KEY,
        {taskset: taskset.key, recalculate: recalculate}.to_json)
    end
842958
def invoke_task(task, args):
    
    parser, proxy_args = get_task_parser(task)
    if proxy_args:
        return task(*args)
    else:
        pargs = parser.parse_args(args)
        return task(**vars(pargs))
1147597
public void enqueue(BaseDownloadTask task) {
        final DownloadTaskAdapter downloadTaskAdapter = (DownloadTaskAdapter) task;
        downloadTaskAdapter.assembleDownloadTask();
        FileDownloadList.getImpl().addIndependentTask(downloadTaskAdapter);
        serialQueue.enqueue(downloadTaskAdapter.getDownloadTask());
        listenerManager.addAutoRemoveListenersWhenTaskEnd(downloadTaskAdapter.getId());
        listenerManager.attachListener(downloadTaskAdapter.getDownloadTask(),
                downloadTaskAdapter.getCompatListener());
    }
932627
def produce(self, func):
        
        # 声明队列
        if not self.task_queue:
            self.ch.queue_declare(queue=self.task_queue, durable=self.durable)
        func(self)
285461
async def async_enqueue_convert(self, converter, from_, to):
        '''
        
        '''
        worker = self.pick_sticky(from_.url_string)
        args = (converter, from_, to)
        await worker.enqueue(enums.Task.CONVERT, args)
502455
public synchronized void enqueue(DownloadTask task) {
        taskList.add(task);
        Collections.sort(taskList);

        if (!paused && !looping) {
            looping = true;
            startNewLooper();
        }
    }
693258
def get_task(self, key):
        """"""
        res, pk = key
        jobs, lock = self._jobs
        with lock:
            return jobs[res].get(pk)
1334360
def enqueue_sync(self, func, *func_args):
        '''
        
        '''
        worker = self.pick_sticky(0)  # just pick first always
        args = (func,) + func_args
        coro = worker.enqueue(enums.Task.FUNC, args)
        asyncio.ensure_future(coro)
1307130
def get_task(client, task_id):
    '''  '''
    endpoint = '/'.join([client.api.Endpoints.TASKS, str(task_id)])
    response = client.authenticated_request(endpoint)
    return response.json()
226992
def add_task(cls, task, frequency=None):
        
        with cls._lock:
            if not isinstance(task, Task):
                t = Task(name=task.__name__, frequency=frequency)
                t.execute, task = task, t

            if frequency:
                task.frequency = frequency

            cls.tasks.append(task)
            cls.tasks.sort()
73647
@GET
  @Path("{taskName}")
  public Response enqueueTask(@PathParam("taskName") String taskName) {
    checkNotNull(taskName);
    taskQueue.enqueueTask(taskName, requestParamsProvider.get());
    return Response.ok().build();
  }