Beispiel #1
0
    def _run_loop(self, run_once=False):
        next_run = None
        current_run = None

        while self.running:
            current_run = timeutils.isotime()
            next_run = time.time() + CONF.scheduler.job_schedule_interval

            # do work
            with utils.log_warning_and_dismiss_exception(LOG):
                self.enqueue_jobs(end_time=current_run)

            # if shutdown hasn't been requested, do nothing until next run
            if self.running:
                seconds = next_run - time.time()
                if seconds > 0:
                    time.sleep(seconds)
                else:
                    msg = _('Scheduling of jobs took longer than expected.')
                    LOG.warn(msg)

            if run_once:
                break

        LOG.info(_('Scheduler is shutting down'))
Beispiel #2
0
    def _run_loop(self, run_once=False):
        next_run = None
        current_run = None

        while self.running:
            current_run = timeutils.isotime()
            next_run = time.time() + CONF.scheduler.job_schedule_interval

            # do work
            with utils.log_warning_and_dismiss_exception(LOG):
                self.enqueue_jobs(end_time=current_run)

            # if shutdown hasn't been requested, do nothing until next run
            if self.running:
                seconds = next_run - time.time()
                if seconds > 0:
                    time.sleep(seconds)
                else:
                    msg = _('Scheduling of jobs took longer than expected.')
                    LOG.warn(msg)

            if run_once:
                break

        LOG.info(_('Scheduler is shutting down'))
Beispiel #3
0
    def _register_worker(self):
        LOG.info(_('Registering worker with pid %s') % str(self.pid))
        while self.running:
            worker = None
            with utils.log_warning_and_dismiss_exception(LOG):
                worker = self.client.create_worker(self.host, self.pid)

            if worker:
                msg = _('Worker has been registered with ID: %s')
                LOG.info(msg % worker['id'])
                return worker['id']

            time.sleep(CONF.worker.job_poll_interval)
Beispiel #4
0
    def _register_worker(self):
        LOG.info(_('Registering worker with pid %s') % str(self.pid))
        while self.running:
            worker = None
            with utils.log_warning_and_dismiss_exception(LOG):
                worker = self.client.create_worker(self.host, self.pid)

            if worker:
                msg = _('Worker has been registered with ID: %s')
                LOG.info(msg % worker['id'])
                return worker['id']

            time.sleep(CONF.worker.job_poll_interval)
Beispiel #5
0
    def _poll_for_next_job(self, poll_once=False):
        job = None

        while job is None and self.running:
            time.sleep(CONF.worker.job_poll_interval)
            LOG.debug(_("Attempting to get next job from API"))
            job = None
            with utils.log_warning_and_dismiss_exception(LOG):
                job = self.client.get_next_job(self.worker_id,
                                               CONF.worker.action_type)['job']

            if poll_once:
                break

        return job
Beispiel #6
0
    def _poll_for_next_job(self, poll_once=False):
        job = None

        while job is None and self.running:
            time.sleep(CONF.worker.job_poll_interval)
            LOG.debug(_("Attempting to get next job from API"))
            job = None
            with utils.log_warning_and_dismiss_exception(LOG):
                job = self.client.get_next_job(self.worker_id,
                                               CONF.worker.action_type)['job']

            if poll_once:
                break

        return job
Beispiel #7
0
    def _register_worker(self):
        LOG.info(_('[%(worker_tag)s] Registering worker with pid %(pid)s')
                 % {'worker_tag': self.get_worker_tag(),
                    'pid': str(self.parent_pid)})
        while self.running:
            worker = None
            with utils.log_warning_and_dismiss_exception(LOG):
                worker = self.client.create_worker(self.host, self.parent_pid)

            if worker:
                self.worker_id = worker['id']
                msg = (_('[%s] Worker has been registered')
                       % self.get_worker_tag())
                LOG.info(msg)
                return self.worker_id

            time.sleep(CONF.worker.job_poll_interval)
Beispiel #8
0
    def _register_worker(self):
        LOG.info(_('[%(worker_tag)s] Registering worker with pid %(pid)s')
                 % {'worker_tag': self.get_worker_tag(),
                    'pid': str(self.parent_pid)})
        while self.running:
            worker = None
            with utils.log_warning_and_dismiss_exception(LOG):
                worker = self.client.create_worker(self.host, self.parent_pid)

            if worker:
                self.worker_id = worker['id']
                msg = (_('[%s] Worker has been registered')
                       % self.get_worker_tag())
                LOG.info(msg)
                return self.worker_id

            time.sleep(CONF.worker.job_poll_interval)
Beispiel #9
0
 def _unregister_worker(self):
     LOG.info(_('Unregistering worker. ID: %s') % self.worker_id)
     with utils.log_warning_and_dismiss_exception(LOG):
         self.client.delete_worker(self.worker_id)
Beispiel #10
0
 def _unregister_worker(self):
     LOG.info(_('[%s] Unregistering worker.') % self.get_worker_tag())
     with utils.log_warning_and_dismiss_exception(LOG):
         self.client.delete_worker(self.worker_id)
Beispiel #11
0
 def mock_method():
     with utils.log_warning_and_dismiss_exception():
         pass
     return True
Beispiel #12
0
 def _unregister_worker(self):
     LOG.info(_('Unregistering worker. ID: %s') % self.worker_id)
     with utils.log_warning_and_dismiss_exception(LOG):
         self.client.delete_worker(self.worker_id)
Beispiel #13
0
 def _unregister_worker(self):
     LOG.info(_('[%s] Unregistering worker.') % self.get_worker_tag())
     with utils.log_warning_and_dismiss_exception(LOG):
         self.client.delete_worker(self.worker_id)