Queue a held job by id
19226
def queue(id)
      Log.debug "Queuing held job id #{id}"
      job = @jobs_by_id[id]
      job.owner = nil
      job.time_start = Time.now
      job.time_end = nil
      job.status = Executor::STATUS_NONE
      self.push(job)
    end
1086842
public void queueJob(Runnable job) {
        try {
            logger.debug("Queueing job {}", job);
            executor.submit(job);
        } catch (RejectedExecutionException e) {
            logger.error("Unable to queue a send-command-job! ", e);
        }
        checkQueueSize();
    }
32532
def find_by_id id, prefixed = false
      # Build a prefixed id if expected
      id = prefixed_id(id) if prefixed
      log_info "find_by_id (#{id}, #{prefixed}) > #{id}"

      # Search in jobs queues
      @jobs.find { |item| item.id == id }
    end
160847
synchronized public String addJob(Job aJob) {
    String id = this.getNextJobID();
    aJob.setJobID(id);
    aJob.setState(Job.WAITING);
    this.addToQueue(aJob);
    return id;	
  }
924619
def submit(self, new_queue = None):
    """"""
    self.status = 'submitted'
    self.result = None
    self.machine_name = None
    if new_queue is not None:
      self.queue_name = new_queue
    for array_job in self.array:
      array_job.status = 'submitted'
      array_job.result = None
      array_job.machine_name = None
    self.submit_time = datetime.now()
    self.start_time = None
    self.finish_time = None
1092719
def wait(self, poll_interval=1, timeout=None, full_data=False):
        

        end_time = None
        if timeout:
            end_time = time.time() + timeout

        while end_time is None or time.time() < end_time:

            job_data = self.collection.find_one({
                "_id": ObjectId(self.id),
                "status": {"$nin": ["started", "queued"]}
            }, projection=({
                "_id": 0,
                "result": 1,
                "status": 1
            } if not full_data else None))

            if job_data:
                return job_data

            time.sleep(poll_interval)
        raise Exception("Waited for job result for %s seconds, timeout." % timeout)
1194827
function findIndex(queue, id) {
  var i = queue.length;
  while (i-- && queue[i].id !== id);
  return i;
}
74594
def get(self, id_):
        
        if self.api.queue_exists(id_):
            return Queue(self, {"queue": {"name": id_, "id_": id_}}, key="queue")
        raise exc.NotFound("The queue '%s' does not exist." % id_)
297890
def handle_lease(queue_name):
    """"""
    owner = request.form.get('owner', request.remote_addr, type=str)
    try:
        task_list = work_queue.lease(
            queue_name,
            owner,
            request.form.get('count', 1, type=int),
            request.form.get('timeout', 60, type=int))
    except work_queue.Error, e:
        return utils.jsonify_error(e)

    if not task_list:
        return flask.jsonify(tasks=[])

    db.session.commit()
    task_ids = [t['task_id'] for t in task_list]
    logging.debug('Task leased: queue=%r, task_ids=%r, owner=%r',
                  queue_name, task_ids, owner)
    return flask.jsonify(tasks=task_list)
852700
def idempotent_job_enqueue(job_name, time, config)
      registered = SidekiqScheduler::RedisManager.register_job_instance(job_name, time)

      if registered
        Sidekiq.logger.info "queueing #{config['class']} (#{job_name})"

        handle_errors { enqueue_job(config, time) }

        SidekiqScheduler::RedisManager.remove_elder_job_instances(job_name)
      else
        Sidekiq.logger.debug { "Ignoring #{job_name} job as it has been already enqueued" }
      end
    end
1077451
def queue_jobs(main_task_path, params_list, queue=None, batch_size=1000):
    
    if len(params_list) == 0:
        return []
    if queue is None:
        task_def = context.get_current_config().get("tasks", {}).get(main_task_path) or {}
        queue = task_def.get("queue", "default")

    from .queue import Queue
    queue_obj = Queue(queue)

    if queue_obj.is_raw:
        raise Exception("Can't queue regular jobs on a raw queue")

    all_ids = []

    for params_group in group_iter(params_list, n=batch_size):

        context.metric("jobs.status.queued", len(params_group))

        # Insert the job in MongoDB
        job_ids = Job.insert([{
            "path": main_task_path,
            "params": params,
            "queue": queue,
            "datequeued": datetime.datetime.utcnow(),
            "status": "queued"
        } for params in params_group], w=1, return_jobs=False)

        all_ids += job_ids

    queue_obj.notify(len(all_ids))
    set_queues_size({queue: len(all_ids)})

    return all_ids
465671
function queue (job, value, put) {
      var ts = timestamp()
      var key = toKey(job, ts)

      var id = hash(job+':'+value)
      if(pending[id]) return null //this job is already queued.
      pending[id] = Date.now()

      if(put === false) {
        //return the job to be queued, to include it in a batch insert.
          return {
          type: 'put', 
          key: Buffer.isBuffer(key) ? key : new Buffer(key), 
          value: Buffer.isBuffer(key) ? value : new Buffer(value)
        }
      } else {
        db.put(key, value)
      }
    }
1071101
def job_delete(self, job_id, wait=True):
		
		job_id = normalize_job_id(job_id)
		self.logger.info('deleting job with id: ' + str(job_id) + ' and callback function: ' + self._jobs[job_id]['callback'].__name__)
		job_desc = self._jobs[job_id]
		with self._job_lock:
			job_desc['enabled'] = False
			if wait and self.job_is_running(job_id):
				job_desc['job'].join()
			del self._jobs[job_id]
1273881
function PendingJob(worker, id, resolve, reject) {
  this.worker = worker;
  this.id = id;
  this.job = co.job(resolve, reject);
  this.timer = null;
}
1120000
function(id) {
        var q = queues[id];
        q.finished = true;

        if (q.aborted) {
            var msg = "transaction " + id + " was aborted";
            _fail(id, msg);
            return;
        }

        // execute success callback
        if (q.onSuccess) {
            var sc=q.scope || q.win;
            q.onSuccess.call(sc, _returnData(q));
        }
    }
253527
def cache_job(self, jid, id_, ret, fun):
        '''
        
        '''
        self.returners['{0}.returner'.format(self.opts['master_job_cache'])]({'jid': jid,
                                                                              'id': id_,
                                                                              'return': ret,
                                                                              'fun': fun})
72546
private static synchronized int setId(Queue queue)
    {
        String queue_string = queue.toString();
        if (!queues.contains(queue_string))
            queues.add(queue_string);
        return queues.indexOf(queue_string);
    }