Add job to the queue

@param  {Function} job
350856
function (job) {
		if (job) {
			if (arguments.length > 1) {
				this.jobs = this.jobs.concat(Array.prototype.slice.call(arguments));
			} else {
				this.jobs.push(job);
			}
		}
		return this;
	}
648977
public static function push($job, $data = '', $queue = null, $connection = null)
    {
        return static::$instance->connection($connection)->push($job, $data, $queue);
    }
160847
synchronized public String addJob(Job aJob) {
    String id = this.getNextJobID();
    aJob.setJobID(id);
    aJob.setState(Job.WAITING);
    this.addToQueue(aJob);
    return id;	
  }
829372
synchronized void jobAdded(JobInProgress job) throws IOException {
    QueueSchedulingInfo qsi = 
      queueInfoMap.get(job.getProfile().getQueueName());
    // qsi shouldn't be null
    // update user-specific info
    Integer i = qsi.numJobsByUser.get(job.getProfile().getUser());
    if (null == i) {
      i = 1;
      // set the count for running tasks to 0
      qsi.mapTSI.numSlotsOccupiedByUser.put(job.getProfile().getUser(),
          Integer.valueOf(0));
      qsi.reduceTSI.numSlotsOccupiedByUser.put(job.getProfile().getUser(),
          Integer.valueOf(0));
    }
    else {
      i++;
    }
    qsi.numJobsByUser.put(job.getProfile().getUser(), i);
    
    // setup scheduler specific job information
    preInitializeJob(job);
    
    LOG.debug("Job " + job.getJobID().toString() + " is added under user " 
              + job.getProfile().getUser() + ", user now has " + i + " jobs");
  }
1225293
public Future<String> queueJob(Callable<String> job) {
        Future<String> future = null;
        try {
            logger.debug("Queueing job {}", job);
            future = executor.submit(job);
        } catch (RejectedExecutionException e) {
            logger.error("Unable to queue a send-command-job! ", e);
        }
        checkQueueSize();
        return future;
    }
1269377
function addJobs(quantity) {
  const startId = jobs.length;
  for (let i = 0; i < quantity; i++) {
    const id = startId + i;
    jobs.push({
      id: id,
      name: 'Item name ' + id,
      type1: 'A',
      type2: 'B',
      active: i % 2 === 0 ? 'Y' : 'N',
      datetime: '200' + i + '-12-28T14:57:00'
    });
  }
}
439413
def add_job(self, id, func, **kwargs):
        

        job_def = dict(kwargs)
        job_def['id'] = id
        job_def['func'] = func
        job_def['name'] = job_def.get('name') or id

        fix_job_def(job_def)

        return self._scheduler.add_job(**job_def)
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);
}
795758
public function addJob(Job\WrappedJob $job, $queue) {
        $qb = $this->conn->createQueryBuilder();
        $qb->insert($this->table_name);
        $qb->values([
            'status' => ':status',
            'job' => ':job',
            'name' => ':name',
            'queue' => ':queue',
            'created_at' => ':created_at',
            'available_at' => ':available_at',
        ]);
        $qb->setParameters([
            'status' => self::JOB_STATUS_CREATED,
            'queue' => $queue,
            'job' => (string) $job,
            'name' => $job->getName(),
        ]);
        $qb->setParameter(':created_at', new \DateTime(), Type::DATETIME);
        $available_at = $job->getDelay()
            ? new \DateTime(sprintf('+%d seconds', $job->getDelay()))
            : new \DateTime();
        $qb->setParameter(':available_at', $available_at, Type::DATETIME);
        $qb->execute();

        return $job->withAddedPayload([
            '_doctrine' => [
                'id' => $this->conn->lastInsertId()
            ]
        ]);
    }
62864
private void makeJobRunning(JobInProgress job, JobSchedulingInfo oldInfo, 
                              QueueInfo qi) {
    // Removing of the job from job list is responsibility of the
    //initialization poller.
    // Add the job to the running queue
    qi.addRunningJob(job);
  }
211856
def add_job(session, command_line, name = 'job', dependencies = [], array = None, exec_dir=None, log_dir = None, stop_on_failure = False, **kwargs):
  """"""
  job = Job(command_line=command_line, name=name, exec_dir=exec_dir, log_dir=log_dir, array_string=array, stop_on_failure=stop_on_failure, kwargs=kwargs)

  session.add(job)
  session.flush()
  session.refresh(job)

  # by default id and unique id are identical, but the id might be overwritten later on
  job.id = job.unique

  for d in dependencies:
    if d == job.unique:
      logger.warn("Adding self-dependency of job %d is not allowed" % d)
      continue
    depending = list(session.query(Job).filter(Job.unique == d))
    if len(depending):
      session.add(JobDependence(job.unique, depending[0].unique))
    else:
      logger.warn("Could not find dependent job with id %d in database" % d)

  if array:
    (start, stop, step) = array
    # add array jobs
    for i in range(start, stop+1, step):
      session.add(ArrayJob(i, job.unique))

  session.commit()

  return job
907570
def _insert_job(self, job):
        

        key = self._job_key(job)

        if self._allow_merging:
            if key in self._job_map:
                job_info = self._job_map[key]

                # decide if we want to trigger a widening
                # if not, we'll simply do the merge
                # TODO: save all previous jobs for the sake of widening
                job_added = False
                if self._allow_widening and self._should_widen_jobs(job_info.job, job):
                    try:
                        widened_job = self._widen_jobs(job_info.job, job)
                        # remove the old job since now we have a widened one
                        if job_info in self._job_info_queue:
                            self._job_info_queue.remove(job_info)
                        job_info.add_job(widened_job, widened=True)
                        job_added = True
                    except AngrJobWideningFailureNotice:
                        # widening failed
                        # fall back to merging...
                        pass

                if not job_added:
                    try:
                        merged_job = self._merge_jobs(job_info.job, job)
                        # remove the old job since now we have a merged one
                        if job_info in self._job_info_queue:
                            self._job_info_queue.remove(job_info)
                        job_info.add_job(merged_job, merged=True)
                    except AngrJobMergingFailureNotice:
                        # merging failed
                        job_info = JobInfo(key, job)
                        # update the job map
                        self._job_map[key] = job_info

            else:
                job_info = JobInfo(key, job)
                self._job_map[key] = job_info

        else:
            job_info = JobInfo(key, job)
            self._job_map[key] = job_info

        if self._order_jobs:
            self._binary_insert(self._job_info_queue, job_info, lambda elem: self._job_sorting_key(elem.job))

        else:
            self._job_info_queue.append(job_info)
1153515
function add(desc, site, fn) {
    // Create new promise to signal when this added queue job is done.
    return $q.fromNode(function(cb) {
      var siteName = site.name;
      // Add to end of promise chain.
      _hds[siteName] = _hds[siteName] || Promise.resolve();
      _hds[siteName] = _hds[siteName].then(function() {
        if (!_stopFlag) {
          // Set current job.
          _currents[siteName] = {
            title: desc,
            message: null,
            fn: fn
          };
          // Update function to update current job's message.
          var update = function(message) {
            if (_currents[siteName]) {
              _currents[siteName].message = message;
            }
          };
          // Run function.
          return $q.try(function() {
            return fn(update);
          });
        }
      })
      // Set current job back to null.
      .finally(function() {
        _currents[siteName] = null;
      })
      .then(function() {
        // Signal job is done.
        cb();
      })
      // Make sure errors get reported to the error service.
      .catch(function(err) {
        // Signal job is done with an error.
        cb(err);
        return errorService.report(err);
      });
    });
  }
283820
public function push( $job, $data = '', $queue = null )
	{
		$queueJob = $this->resolveJob( $this->createPayload( $job, $data, $queue ) );

		try
		{
			$this->raiseBeforeJobEvent( $queueJob );

			$queueJob->fire();

			$this->raiseAfterJobEvent( $queueJob );
		}
		catch ( Exception $e )
		{
			$this->raiseExceptionOccurredJobEvent( $queueJob, $e );

			$this->handleFailedJob( $queueJob );

			throw $e;
		}
		catch ( Throwable $e )
		{
			$this->raiseExceptionOccurredJobEvent( $queueJob, $e );

			$this->handleFailedJob( $queueJob );

			throw $e;
		}

		return 0;
	}
303068
def add_job_to_db(self, key, job):
        """"""
        job_msg = self.registry.deep_encode(job)
        prov = prov_key(job_msg)

        def set_link(duplicate_id):
            self.cur.execute(
                'update "jobs" set "link" = ?, "status" = ? where "id" = ?',
                (duplicate_id, Status.DUPLICATE, key))

        with self.lock:
            self.cur.execute(
                'select * from "jobs" where "prov" = ? '
                'and (("result" is not null) or '
                '("session" = ? and "link" is null))',
                (prov, self.session))
            rec = self.cur.fetchone()
            rec = JobEntry(*rec) if rec is not None else None

            self.cur.execute(
                'update "jobs" set "prov" = ?, "version" = ?, "function" = ?, '
                '"arguments" = ?, "status" = ? where "id" = ?',
                (prov, job_msg['data']['hints'].get('version'),
                 json.dumps(job_msg['data']['function']),
                 json.dumps(job_msg['data']['arguments']),
                 Status.WAITING,
                 key))

            if not rec:
                # no duplicate found, go on
                return 'initialized', None

            set_link(rec.id)

            if rec.result is not None and rec.status == Status.WORKFLOW:
                # the found duplicate returned a workflow
                if rec.link is not None:
                    # link is set, so result is fully realized
                    self.cur.execute(
                        'select * from "jobs" where "id" = ?',
                        (rec.link,))
                    rec = self.cur.fetchone()
                    assert rec is not None, "database integrity violation"
                    rec = JobEntry(*rec)

                else:
                    # link is not set, the result is still waited upon
                    assert rec.session == self.session, \
                        "database integrity violation"
                    self.attached[rec.id].append(key)
                    return 'attached', None

            if rec.result is not None:
                # result is found! return it
                result_value = self.registry.from_json(rec.result, deref=True)
                result = ResultMessage(
                    key, 'retrieved', result_value, None)
                return 'retrieved', result

            if rec.session == self.session:
                # still waiting for result, attach
                self.attached[rec.id].append(key)
                return 'attached', None
740909
public function push(Job $job, $queueName = '')
    {
        if (!isset($this->queues[$queueName])) {
            $this->queues[$queueName] = [];
        }

        $this->queues[$queueName][] = $job;

        return Queue::QUEUED;

    }
820714
public function push($job, $data = '', $queue = null)
    {
        $queueJob = $this->resolveJob($this->createPayload($job, $data, $queue), $queue);

        $queueJob->handle();

        return 0;
    }