We do not want a single failure to affect the whole scheduler.
@param job job to execute.
555565
void executeInABox(final Job job) {
        try {
            job.execute();
        } catch (Exception e) {
            System.err.println("The execution of the job threw an exception");
            e.printStackTrace(System.err);
        }
    }
476082
protected function raiseFailedJobEvent(Job $job)
	{
		$data = json_decode($job->getRawBody(), true);

		if($this->container->bound('events'))
		{
			$this->container['events']->fire('illuminate.queue.failed', array('sync', $job, $data));
		}
	}
1044879
private void unlockJob() {
    if (this.jobLockOptional.isPresent()) {
      try {
        // Unlock so the next run of the same job can proceed
        this.jobLockOptional.get().unlock();
      } catch (JobLockException ioe) {
        LOG.error(String.format("Failed to unlock for job %s: %s", this.jobContext.getJobId(), ioe), ioe);
      } finally {
        try {
          this.jobLockOptional.get().close();
        } catch (IOException e) {
          LOG.error(String.format("Failed to close job lock for job %s: %s", this.jobContext.getJobId(), e), e);
        } finally {
          this.jobLockOptional = Optional.absent();
        }
      }
    }
  }
442862
public void purgeJob(final HadoopJob job) {
    runningJobs.remove(job.getJobID());
    Display.getDefault().asyncExec(new Runnable() {
      public void run() {
        fireJobRemoved(job);
      }
    });
  }
302050
protected void process(final Job job, final String curQueue) {
        boolean success = false;
        try {
            this.processingJob.set(true);
            if (threadNameChangingEnabled) {
                renameThread("Processing " + curQueue + " since " + System.currentTimeMillis());
            }
            this.listenerDelegate.fireEvent(JOB_PROCESS, this, curQueue, job, null, null, null);
            this.jedis.set(key(WORKER, this.name), statusMsg(curQueue, job));
            final Object instance = this.jobFactory.materializeJob(job);
            final Object result = execute(job, curQueue, instance);
            success(job, instance, result, curQueue);
            success = true;
        } catch (Throwable thrwbl) {
            failure(thrwbl, job, curQueue);
        } finally {
            removeInFlight(curQueue, success);
            this.jedis.del(key(WORKER, this.name));
            this.processingJob.set(false);
        }
    }
617880
public function enqueue(Job $job): void
    {
        $queue = $job->getQueue();

        $this->client->sadd('queue', [$queue]);

        $this->client->rpush(
            sprintf('queue:%s', $queue),
            [
                json_encode($job->getPayload()),
            ]
        );
    }
811279
void preInitializeJob(JobInProgress job) {
    JobConf jobConf = job.getJobConf();
    
    // Compute number of slots required to run a single map/reduce task
    int slotsPerMap = 1;
    int slotsPerReduce = 1;
    if (memoryMatcher.isSchedulingBasedOnMemEnabled()) {
      slotsPerMap = jobConf.computeNumSlotsPerMap(getMemSizeForMapSlot());
     slotsPerReduce = 
       jobConf.computeNumSlotsPerReduce(getMemSizeForReduceSlot());
    }
    job.setNumSlotsPerMap(slotsPerMap);
    job.setNumSlotsPerReduce(slotsPerReduce);
  }
1010220
public function deleteReserved($queue, $job)
    {
        parent::deleteReserved($queue, $job);

        $this->event($this->getQueue($queue), new JobDeleted($job, $job->getReservedJob()));
    }
56609
function (err) {
		if (this.jobs.length) {
			var job = this.jobs.shift();
			try {
				job(err, this);
			} catch (e) {
				this.next(e);
			}
		} else {
			this.running = false;
		}
	}
222023
protected function handleJobException(Job $job, ListenerOptions $options, $e)
    {
        try {
            // First, we will go ahead and mark the job as failed if it will exceed the maximum
            // attempts it is allowed to run the next time we process it. If so we will just
            // go ahead and mark it as failed now so we do not have to release this again.
            $this->markJobAsFailedIfWillExceedMaxAttempts($job, (int) $options->maxTries, $e);

            $this->raiseExceptionOccurredJobEvent($job, $e);
        } finally {
            if (!$job->isDeleted()) {
                $job->release($options->delay);
            }
        }

        throw $e;
    }
38492
protected function markJobAsFailedIfWillExceedMaxAttempts(Job $job, $maxTries, $e)
    {
        if ($maxTries > 0 && $job->attempts() >= $maxTries) {
            $this->failJob($job, $e);
        }
    }
634680
def cancel(self, job):
        
        if isinstance(job, self.job_class):
            self.connection.zrem(self.scheduled_jobs_key, job.id)
        else:
            self.connection.zrem(self.scheduled_jobs_key, job)
1301191
public function workingOn(Job &$job)
    {
        $this->job = $job;
        $job->setWorker($this);

        Event::fire(Event::WORKER_WORKING_ON, array($this, $job));

        $this->redis->hmset(self::redisKey($this), array(
            'job_id'      => $job->getId(),
            'job_started' => microtime(true)
        ));
    }
845562
public void executeJob(String jobName) throws MangooSchedulerException {
        Objects.requireNonNull(this.quartzScheduler, Required.SCHEDULER.toString());
        Objects.requireNonNull(jobName, Required.JOB_NAME.toString());
        
        try {
            for (JobKey jobKey : getAllJobKeys()) {
                if (jobKey.getName().equalsIgnoreCase(jobName)) {
                    this.quartzScheduler.triggerJob(jobKey);  
                }
            }
        } catch (SchedulerException | MangooSchedulerException e) {
            throw new MangooSchedulerException(e);
        }
    }
402057
public boolean isScheduled(final org.easybatch.core.job.Job job) throws JobSchedulerException {
        String jobName = job.getName();
        try {
            return scheduler.checkExists(TriggerKey.triggerKey(TRIGGER_NAME_PREFIX + jobName));
        } catch (SchedulerException e) {
            throw new JobSchedulerException(format("Unable to check if the job '%s' is scheduled", jobName), e);
        }
    }
1266857
public synchronized void checkValidPoolProperty(JobInProgress job)
      throws InvalidJobConfException {
    if (!strictPoolsMode) {
      return;
    }

    JobConf conf = job.getJobConf();
    // Pool name needs to be lower cased.
    String poolName = conf.get(EXPLICIT_POOL_PROPERTY);
    if (poolName == null) {
      return;
    } else {
      poolName = poolName.toLowerCase();
    }

    if (poolNamesInAllocFile.contains(poolName)) {
      return;
    }

    throw new InvalidJobConfException(
        "checkValidPoolProperty: Pool name " +
        conf.get(EXPLICIT_POOL_PROPERTY) + " set with Hadoop property " +
        EXPLICIT_POOL_PROPERTY + " does not exist.  " +
        "Please check for typos in the pool name.");
  }
543061
public void unscheduleJob(String jobName)
      throws JobException {
    if (this.scheduledJobs.containsKey(jobName)) {
      try {
        this.scheduler.getScheduler().deleteJob(this.scheduledJobs.remove(jobName));
      } catch (SchedulerException se) {
        LOG.error("Failed to unschedule and delete job " + jobName, se);
        throw new JobException("Failed to unschedule and delete job " + jobName, se);
      }
    }
  }