Schedule a worker for shutdown. Will finish processing the current job
and when the timeout interval is reached, the worker will shut down.
422419
public function shutdown()
    {
        if ($this->childPID) {
            $this->logger->notice('{type}: QUIT received; shutting down after child completes work', $this->logContext);
        } else {
            $this->logger->notice('{type}: QUIT received; shutting down', $this->logContext);
        }
        $this->doShutdown();
    }
1345563
function() {
        // Important to configure later to not use UTC.
        later.date.localTime();

        // Shutdown on schedule.
        if (this.get('shutdownSchedule')) {
            this._shutdownSchedule = later.parse.cron(this.get('shutdownSchedule'));
            if (this._shutdownInterval) {
                this._shutdownInterval.clear();
            }

            this._shutdownInterval = later.setInterval(_.bind(function() {
                logger.info('App shutdown time has arrived. ' + new Date());
                this.set('restartCount', 0);
                this.shutdownApp();
            }, this), this._shutdownSchedule);
        }

        // Shutdown on schedule.
        if (this.get('shutdownPcSchedule')) {
            this._shutdownPcSchedule = later.parse.cron(this.get('shutdownPcSchedule'));
            if (this._shutdownPcInterval) {
                this._shutdownPcInterval.clear();
            }

            this._shutdownPcInterval = later.setInterval(_.bind(function() {
                logger.info('Machine shutdown time has arrived. ' + new Date());
                this.set('restartCount', 0);
                this.shutdownMachine();
            }, this), this._shutdownPcSchedule);
        }

        // Start up on schedule.
        if (this.get('startupSchedule')) {
            this._startupSchedule = later.parse.cron(this.get('startupSchedule'));
            if (this._startupInterval) {
                this._startupInterval.clear();
            }

            this._startupInterval = later.setInterval(_.bind(function() {
                logger.info('App startup time has arrived. ' + new Date());
                if (!$$serverState.get('runApp')) {
                    logger.info('Startup disabled by console.');
                    return;
                }

                this.set('restartCount', 0);
                this.startApp();
            }, this), this._startupSchedule);
        }

        // Start up on schedule.
        if (this.get('restartSchedule')) {
            this._restartSchedule = later.parse.cron(this.get('restartSchedule'));
            if (this._restartInterval) {
                this._restartInterval.clear();
            }

            this._restartInterval = later.setInterval(_.bind(function() {
                if (this._isStartingUp || this._isShuttingDown) {
                    return;
                }

                logger.info('App restart time has arrived. ' + new Date());
                if (!$$serverState.get('runApp')) {
                    logger.info('Startup disabled by console.');
                    return;
                }

                this.set('restartCount', 0);
                this.restartApp();
            }, this), this._restartSchedule);
        }

        // Restart machine on schedule.
        if (this.get('restartPcSchedule')) {
            this._restartPcSchedule = later.parse.cron(this.get('restartPcSchedule'));
            if (this._restartPcInterval) {
                this._restartPcInterval.clear();
            }

            this._restartPcInterval = later.setInterval(_.bind(function() {
                logger.info('Machine restart time has arrived. ' + new Date());

                this.restartMachine();

            }, this), this._restartPcSchedule);
        }

    }
534004
private function cancelPending()
    {
        if (!$this->busyQueue->isEmpty()) {
            $exception = new WorkerException('Worker was shut down.');

            do {
                $this->busyQueue->dequeue()->cancel($exception);
            } while (!$this->busyQueue->isEmpty());
        }
    }
585912
def process(job = nil, &block)
      return unless job ||= reserve

      job.worker = self
      working_on job
      perform(job, &block)
    ensure
      done_working
    end
241605
def _scheduleRestart(self,
                         when: Union[datetime, str],
                         failTimeout) -> None:
        
        logger.info("{}'s restarter processing restart"
                    .format(self))
        if isinstance(when, str):
            when = dateutil.parser.parse(when)
        now = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc())

        logger.info(
            "Restart of node '{}' has been scheduled on {}".format(
                self.nodeName, when))

        ev_data = RestartLogData(when)
        self._actionLog.append_scheduled(ev_data)

        callAgent = partial(self._callRestartAgent, ev_data,
                            failTimeout)
        delay = 0
        if now < when:
            delay = (when - now).total_seconds()
        self.scheduledAction = ev_data
        self._schedule(callAgent, delay)
594841
public static void shutDown()
    {
        if (Quartz.QUARTZ != null && Quartz.QUARTZ.scheduler != null) {
            try {
                Quartz.QUARTZ.scheduler.shutdown();
            } catch (final SchedulerException e) {
                Quartz.LOG.error("Problems on shutdown of QuartsSheduler", e);
            }
        }
    }
916789
def shutdown(self):
        
        self.shutdownLocal()
        newJobsQueue = self.newJobsQueue
        self.newJobsQueue = None

        newJobsQueue.put(None)
        self.worker.join()
84593
async def shutdown(self, connmark = -1):
        '''
        
        '''
        if connmark is None:
            connmark = self.connmark
        self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.SHUTDOWN, True, connmark))
8972
private synchronized void schedule(final ScheduledJobEntry newSJE) {
        // disallow new jobs after shutdown
        if (shutdown) {
            return;
        }
        int max = jobList.size();
        long desiredExecutionTime = newSJE.desiredExecutionTime;

        // find the index i such that timeInMillis < jobList[i]
        int i = 0;
        for (; i < max; i++) {

            ScheduledJobEntry sje = (ScheduledJobEntry) jobList.get(i);

            if (desiredExecutionTime < sje.desiredExecutionTime) {
                break;
            }
        }
        jobList.add(i, newSJE);
        // if the jobList was empty, then notify the scheduler thread
        if (i == 0) {
            this.notifyAll();
        }
    }
1140539
public function forceShutdown()
    {
        Event::fire(Event::WORKER_FORCE_SHUTDOWN, $this);

        if ($this->child === 0) {
            $this->log('Forcing shutdown of job <pop>'.$this->job.'</pop>', Logger::NOTICE);
        } else {
            $this->log('Forcing shutdown of worker <pop>'.$this.'</pop>', Logger::NOTICE);
        }

        $this->shutdown();
        $this->killChild();
    }
272644
public synchronized void shutdown() {
    if (!isActive) {
      return;
    }
    log.info("Shutting down the default async job executor [{}].", getClass().getName());
    
    if (timerJobRunnable != null) {
      timerJobRunnable.stop();
    }
    if (asyncJobsDueRunnable != null) {
      asyncJobsDueRunnable.stop();
    }
    if (resetExpiredJobsRunnable != null) {
      resetExpiredJobsRunnable.stop();
    }
    
    stopResetExpiredJobsThread();
    stopTimerAcquisitionThread();
    stopJobAcquisitionThread();
    stopExecutingAsyncJobs();

    timerJobRunnable = null;
    asyncJobsDueRunnable = null;
    resetExpiredJobsRunnable = null;
    
    isActive = false;
  }
825892
@Override
  public void shutdown() {

    // delay a little bit in case an added job is still taking it's time getting started right
    // before shutdown is called.
    try {
      //      System.out.println("waiting...");
      Thread.sleep(100);
    } catch (Exception ignore) {
    }

    if (shuttingDown || closed) {
      return;
    }

    shuttingDown = true;

    logger.info("Scheduler shutting down...");

    standby();

    this.quartzSchedulerThread.halt();

    notifySchedulerListenersShuttingdown();

    // notify Jobs, so they can gracefully shutdown
    List<JobExecutionContext> jobs = getCurrentlyExecutingJobs();
    for (JobExecutionContext job : jobs) {
      if (job.getJobInstance() instanceof InterruptableJob) {
        try {
          ((InterruptableJob) job.getJobInstance()).interrupt();
        } catch (Throwable e) {
          // do nothing, this was just a courtesy effort
          logger.warn(
              "Encountered error when interrupting job {} during shutdown: {}",
              job.getJobDetail().getName(),
              e);
        }
      }
    }

    logger.info("Threadpool shutting down...");
    quartzSchedulerResources.getThreadPool().shutdown();

    // Scheduler thread may have be waiting for the fire time of an acquired
    // trigger and need time to release the trigger once halted, so make sure
    // the thread is dead before continuing to shutdown the job store.
    try {
      this.quartzSchedulerThread.join();
    } catch (InterruptedException ignore) {
    }

    closed = true;

    shutdownPlugins();

    notifySchedulerListenersShutdown();

    logger.info("Scheduler shutdown complete.");
  }
484191
def run(self):
        ''''''
        # Register our signal handlers
        self.signals()

        with self.listener():
            for job in self.jobs():
                # If there was no job to be had, we should sleep a little bit
                if not job:
                    self.jid = None
                    self.title('Sleeping for %fs' % self.interval)
                    time.sleep(self.interval)
                else:
                    self.jid = job.jid
                    self.title('Working on %s (%s)' % (job.jid, job.klass_name))
                    with Worker.sandbox(self.sandbox):
                        job.sandbox = self.sandbox
                        job.process()
                if self.shutdown:
                    break
1364367
public synchronized void shutdownTaskScheduler(){
        if (scheduler != null && !scheduler.isShutdown()) {
            scheduler.shutdown();
            logger.info("shutdowned the task scheduler. No longer accepting new tasks");
            scheduler = null;
        }
    }
1304769
def shutdown(self):
        
        # Drop all pending item from the executor. Without this, the executor
        # will block until all pending items are complete, which is
        # undesirable.
        try:
            while True:
                self._executor._work_queue.get(block=False)
        except queue.Empty:
            pass
        self._executor.shutdown()
509978
public function shutdown()
    {
        $this->shutdown = true;
        $this->redis->hmset(self::redisKey($this), 'shutdown', true);

        Event::fire(Event::WORKER_SHUTDOWN, $this);
    }
199322
public void shutdown() {
        // shutdown each single thread executor in the managed collection
        for (ExecutorService singleThreadExecutorService : singleThreadExecutorServices) {
            shutdownExecutor(singleThreadExecutorService);
        }

        // shutdown scheduled executor instance
        shutdownExecutor(getInternalScheduledExecutorService());
        shutdownExecutor(getInternalGpioExecutorService());

    }