Enqueue a batch of jobs.
185876
def enqueue_jobs(self, jobs: Iterable[Job]):
        """"""
        for job in jobs:
            if job.should_start:
                job.status = JobStatus.QUEUED
                queue = self._get_queue(job.queue)
                queue.put(job.serialize())
            else:
                with self._lock:
                    job.status = JobStatus.WAITING
                    self._future_jobs.append(job.serialize())
                    self._future_jobs.sort(key=lambda j: Job.deserialize(j).at)
        self._something_happened.set()
1249342
def build_from_queue(cls, input_queue, replay_size, batch_size):
    
    return cls(
        lambda: input_queue.dequeue_many(batch_size),
        replay_size,
        batch_size=batch_size)
357414
def start(self):
        """"""
        if self.num_workers:
            self.queue = Queue(maxsize=self.num_workers)
            self.workers = [_Worker(self) for _ in range(self.num_workers)]
            for worker in self.workers:
                worker.start()
        self.running = True
382879
def enqueue_data(self, event_type, data):
        """"""

        with self.lock:
            listeners = self.listeners.values()
            for listener in listeners:
                listener.enqueue(event_type, data)
                self.must_process = True
45341
def enqueue(self, payload, interval, job_id,
                queue_id, queue_type='default', requeue_limit=None):
        
        # validate all the input
        if not is_valid_interval(interval):
            raise BadArgumentException('`interval` has an invalid value.')

        if not is_valid_identifier(job_id):
            raise BadArgumentException('`job_id` has an invalid value.')

        if not is_valid_identifier(queue_id):
            raise BadArgumentException('`queue_id` has an invalid value.')

        if not is_valid_identifier(queue_type):
            raise BadArgumentException('`queue_type` has an invalid value.')

        if requeue_limit is None:
            requeue_limit = self._default_job_requeue_limit

        if not is_valid_requeue_limit(requeue_limit):
            raise BadArgumentException('`requeue_limit` has an invalid value.')

        try:
            serialized_payload = serialize_payload(payload)
        except TypeError as e:
            raise BadArgumentException(e.message)

        timestamp = str(generate_epoch())

        keys = [
            self._key_prefix,
            queue_type
        ]

        args = [
            timestamp,
            queue_id,
            job_id,
            '"%s"' % serialized_payload,
            interval,
            requeue_limit
        ]

        self._lua_enqueue(keys=keys, args=args)

        response = {
            'status': 'queued'
        }
        return response
35542
public function bulk($jobs, $data = '', $queue = null)
    {
        foreach ((array) $jobs as $job) {
            $this->push($job, $data, $queue);
        }
    }
79151
def _run_raw(self, *args, **kwargs):
    """"""
    for job in self.jobs:
      job._run_raw(*args, **kwargs)
1267331
def _get_batches(self, items):
        """"""
        for i in xrange(0, len(items), self.max_batch_size):
            yield items[i:i + self.max_batch_size]
252798
def _munch_off_batch(self, queue):
        
        """

        # if the number of CPUs used == 1, just pop one off (which == below)
        # elif the the number of things in the queue is 1, use all the CPUs and just that hmm
        if len(queue) == 1 or self._num_cpus == 1:
            pairs_to_run = [[queue.pop(0), self._num_cpus]]
        else:
            # else share out CPUs among hmmers
            pairs_to_run = []
            while len(queue) > 0 and len(pairs_to_run) < self._num_cpus:
                pairs_to_run.append([queue.pop(0), 1])
            # Share out any remaining CPUs
            num_cpus_left = self._num_cpus - len(pairs_to_run)
            while num_cpus_left > 0:
                for i, _ in enumerate(pairs_to_run):
                    pairs_to_run[i][1] += 1
                    num_cpus_left -= 1
                    if num_cpus_left == 0: break

        return pairs_to_run
144187
def enqueue(self, job):
    
    if job.queue_name():
      raise EnqueueError("job %s already queued!" % job.job_id)
    new_len = self.redis.lpush(self.queue_name, job.serialize())
    job.notify_queued(self)
    return new_len
1094031
public function enqueue()
    {
        $this->outputTitle('Queuing a job');

        $args = $this->input->getArguments();

        if (count($args) >= 2) {
            $queue = array_shift($args);
            $class = array_shift($args);

            $result = call_user_func_array(self::$Resque . '::enqueue', array($queue, $class, $args));
            $this->output->outputLine('The job was enqueued successfully', 'success');
            $this->output->outputLine('Job ID : #' . $result . "\n");
        } else {
            $this->output->outputLine('Enqueue takes at least 2 arguments', 'failure');
            $this->output->outputLine('Usage : enqueue <queue> <job> <args>');
            $this->output->outputLine('   queue <string>  Name of the queue');
            $this->output->outputLine('   job   <string>  Job class name');
            $this->output->outputLine('   args  <string>  Comma separated list of arguments');
            $this->output->outputLine();
        }
    }
675642
def build_from_job_list(scheme_files, templates, base_output_dir):
    """"""
    queue = Queue()
    for scheme in scheme_files:
        queue.put(scheme)

    if len(scheme_files) < 40:
        thread_num = len(scheme_files)
    else:
        thread_num = 40

    threads = []
    for _ in range(thread_num):
        thread = Thread(target=build_single_worker,
                        args=(queue, templates, base_output_dir))
        thread.start()
        threads.append(thread)

    queue.join()

    for _ in range(thread_num):
        queue.put(None)

    for thread in threads:
        thread.join()
1038366
def batch(self):
        """"""
        _batch = []
        yield _batch
        if _batch:
            new_part = super(type(self), type(self)).empty()
            new_part._from_entities(_batch, _batch[0].__dimension__)
            self.concat(new_part, inplace=True)
1296651
function JobQueue(para) {
	this.queue = [];
	this.curr = 0;
	this.all_passed = true;
	this.timeout = ((typeof para === 'object' && typeof para.timeout === 'number') ? para.timeout : 0);
}
1216080
def enqueue_taskset(taskset)
      RRRSpec.redis.rpush(RRRSpec.make_key(key, 'worker_queue'), taskset.key)
    end
381408
def register_jobs(self, job_dict):
        """"""
        njobs = len(job_dict)
        sys.stdout.write("Registering %i total jobs: " % njobs)
        for i, job_details in enumerate(job_dict.values()):
            if i % 10 == 0:
                sys.stdout.write('.')
                sys.stdout.flush()
            self.register_job(job_details)
        sys.stdout.write('!\n')
1105384
def batch!(request, request_options = {})
      res = batch(request, request_options)
      wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      res
    end