Used internally.

        Cleans up the sched references in the proactor. If you use this don't use
        it while the :class:`Scheduler` (:func:`run`) is still running.
12747
def cleanup(self):
        

        if hasattr(self, 'proactor'):
            if hasattr(self.proactor, 'scheduler'):
                del self.proactor.scheduler
            if hasattr(self.proactor, 'close'):
                self.proactor.close()
686049
def unschedule(name, params):
    '''
    
    '''
    if name not in celery.tasks:
        exit_with_error('Job %s not found', name)

    args = [p for p in params if '=' not in p]
    kwargs = dict(p.split('=') for p in params if '=' in p)
    label = 'Job {0}'.format(job_label(name, args, kwargs))

    try:
        task = PeriodicTask.objects.get(task=name, args=args, kwargs=kwargs)
    except PeriodicTask.DoesNotExist:
        exit_with_error('No scheduled job match {0}'.format(label))

    task.delete()
    msg = 'Unscheduled {label} with the following crontab: {cron}'
    log.info(msg.format(label=label, cron=task.schedule_display))
1290043
def _pre_run(self, pre_run=None):
        "  "
        if pre_run:
            pre_run()

        # Process registered "pre_run_callables" and clear list.
        for c in self.pre_run_callables:
            c()
        del self.pre_run_callables[:]
116261
def _unscheduleAction(self):
        
        logger.trace("{} unscheduling actions".format(self))
        self.aqStash = deque()
        self.scheduledAction = None
28797
async def clean(self):
        
        for x in self._running_asyncio_tasks:
            x.cancel()
        self._container_had_error = set()
        self._watching = set()
        self._running_asyncio_tasks = set()
241857
def run(self, schedule_id, **kwargs):
        
        log = self.get_logger(**kwargs)

        try:
            schedule = Schedule.objects.get(id=schedule_id)
        except Schedule.DoesNotExist:
            log.error("Missing Schedule %s", schedule_id, exc_info=True)

        if schedule.scheduler_schedule_id is None:
            # Create the new schedule
            result = self.scheduler.create_schedule(schedule.scheduler_format)
            schedule.scheduler_schedule_id = result["id"]
            # Disable update signal here to avoid calling twice
            post_save.disconnect(schedule_saved, sender=Schedule)
            schedule.save(update_fields=("scheduler_schedule_id",))
            post_save.connect(schedule_saved, sender=Schedule)

            log.info(
                "Created schedule %s on scheduler for schedule %s",
                schedule.scheduler_schedule_id,
                schedule.id,
            )
        else:
            # Update the existing schedule
            result = self.scheduler.update_schedule(
                str(schedule.scheduler_schedule_id), schedule.scheduler_format
            )
            log.info(
                "Updated schedule %s on scheduler for schedule %s",
                schedule.scheduler_schedule_id,
                schedule.id,
            )
1294382
def schedule_deleted(sender, instance, **kwargs):
    
    from contentstore.tasks import deactivate_schedule

    deactivate_schedule.delay(str(instance.scheduler_schedule_id))
712648
def cleanup(self):
        
        inserts = []

        last_run = self._runs[self._last_run_id]
        if 'end' not in last_run:
            last_run['end'] = datetime.now()

        for run_id in sorted(self._runs):
            run = self._runs[run_id]
            d = {'run-id': run.get('run-id', -1)}
            for key in self._run_keys:
                if key in run:
                    d[key] = run[key]
            inserts.append(('run', d))

        # reset for next task
        self._parse_id = -1
        self._runs = {}
        self._last_run_id = -1

        return inserts
1284976
def run(self, **kwargs):
        
        log = self.get_logger(**kwargs)
        failures = ScheduleFailure.objects
        log.info("Attempting to requeue <%s> failed schedules" % failures.count())
        for failure in failures.iterator():
            schedule = Schedule.objects.values(
                "id", "auth_token", "endpoint", "payload"
            )
            schedule = schedule.get(id=failure.schedule_id)
            schedule["schedule_id"] = str(schedule.pop("id"))
            # Cleanup the failure before requeueing it.
            failure.delete()
            DeliverTask.apply_async(kwargs=schedule)
796086
def run_on_removals(paths)
      Runner.remove(Inspector.clean(paths, :missing_ok => true), watchers, options)
    end
1334963
def _scheduleMePlease(self):
        
        sched = IScheduler(self.store)
        if len(list(sched.scheduledTimes(self))) == 0:
            sched.schedule(self, sched.now())
1082832
def update(time)
            @last_scheduled = @reactor.now

            parsed_time = Scheduler.parse_in(time, :quiet)
            if parsed_time.nil?
                # Parse at will throw an error if time is invalid
                parsed_time = Scheduler.parse_at(time) - @scheduler.time_diff
            else
                parsed_time += @last_scheduled
            end

            @next_scheduled = parsed_time
            @scheduler.reschedule(self)
        end
584321
def cleaner(self):
        
        while True:
            self.cleanup()
            now = time.time()
            try:
                while (time.time() - now) < self.clean_interval:
                    if not self.run_clean_thread:
                        return
                    time.sleep(1)
            except:
                return
1051055
def cleanup_sweep_threads():
    '''
    
    '''

    for dict_name, obj in globals().items():
        if isinstance(obj, (TimedDict,)):
            logging.info(
                'Stopping thread for TimedDict {dict_name}'.format(
                    dict_name=dict_name))
            obj.stop_sweep()
88658
def run_job(self, name):
        '''
        
        '''
        data = self._get_schedule().get(name, {})

        if 'function' in data:
            func = data['function']
        elif 'func' in data:
            func = data['func']
        elif 'fun' in data:
            func = data['fun']
        else:
            func = None
        if not isinstance(func, list):
            func = [func]
        for _func in func:
            if _func not in self.functions:
                log.error(
                    'Invalid function: %s in scheduled job %s.',
                    _func, name
                )

        if 'name' not in data:
            data['name'] = name
        log.info('Running Job: %s', name)

        # Grab run, assume True
        run = data.get('run', True)
        if run:
            self._run_job(_func, data)
263669
public function runSchedule()
    {
        if ($this->getScheduler()->isEmpty()) {
            return;
        }

        if (!$this->getScheduler()->top()->isDue()) {
            // Nothing to do.
            return;
        }

        $schedule = $this->getScheduler()->extract();

        $this->getLogger()->debug('Running schedule '.$schedule->getName().' with expression: '.$schedule->getExpression().'.');
        $schedule->run();

        $this->getScheduler()->insert($schedule);
    }
989947
private void cleanup() {
        StatsDataReference ref = null;
        while ((ref = (StatsDataReference) statisticsReferenceQueue.poll()) != null) {
            StatsData oldStats = null;
            StatsData updatedStats = null;
            do {
                oldStats = terminatedThreadStats.get();
                updatedStats = aggregateStats(oldStats, ref.statsData);
            } while (!terminatedThreadStats.compareAndSet(oldStats, updatedStats));
            allReferences.remove(ref);
        }
    }