Called periodically by the cron daemon, if True Run() will be called.

    Returns:
        True if it is time to run based on the specified frequency.
558940
def DueToRun(self):
    
    if self.Get(self.Schema.DISABLED):
      return False

    cron_args = self.Get(self.Schema.CRON_ARGS)
    last_run_time = self.Get(self.Schema.LAST_RUN_TIME)
    now = rdfvalue.RDFDatetime.Now()

    # Its time to run.
    if (last_run_time is None or
        now > cron_args.periodicity.Expiry(last_run_time)):

      # Not due to start yet.
      if now < cron_args.start_time:
        return False

      # Do we allow overruns?
      if cron_args.allow_overruns:
        return True

      # No currently executing job - lets go.
      if self.Get(self.Schema.CURRENT_FLOW_URN) is None:
        return True

    return False
1347825
def _run(self):
        
        self._is_running = True
        network_fail = False
        try:
            while self._do_run:
                try:
                    if network_fail is True:
                        LOGGER.info("Network connection re-established!")
                        network_fail = False
                    self._sender(self._message)
                except IOError as err:
                    if err.errno == errno.ENETUNREACH:
                        LOGGER.error("Network unreachable. "
                                     "Trying again in %d s.",
                                     self._interval)
                        network_fail = True
                    else:
                        raise
                time.sleep(self._interval)
        finally:
            self._is_running = False
            self._sender.close()
1081593
def IsRunning(self):
    """"""
    current_urn = self.Get(self.Schema.CURRENT_FLOW_URN)
    if not current_urn:
      return False

    try:
      current_flow = aff4.FACTORY.Open(
          urn=current_urn, aff4_type=flow.GRRFlow, token=self.token, mode="r")
    except aff4.InstantiationError:
      # This isn't a flow, something went really wrong, clear it out.
      logging.error("Unable to open cron job run: %s", current_urn)
      self.DeleteAttribute(self.Schema.CURRENT_FLOW_URN)
      self.Flush()
      return False

    return current_flow.GetRunner().IsRunning()
1111101
def is_running(self):
        
        pid = self.get_pid()
        if pid is None:
            return False
        # The PID file may still exist even if the daemon isn't running,
        # for example if it has crashed.
        try:
            os.kill(pid, 0)
        except OSError as e:
            if e.errno == errno.ESRCH:
                # In this case the PID file shouldn't have existed in
                # the first place, so we remove it
                self.pid_file.release()
                return False
            # We may also get an exception if we're not allowed to use
            # kill on the process, but that means that the process does
            # exist, which is all we care about here.
        return True
286403
def _setup_server():
    
    if args["setup"] or args["install"]:
        #If the cron has been configured, it means that the server has been
        #setup. We also perform some checks of the configuration file and the
        #existence of the virtualenv.
        if not _check_global_settings() or not _check_virtualenv():
            return False

        _cron_profile()
        if "cron" in db and not db["cron"]:
            _setup_crontab()

    if args["rollback"]:
        _setup_crontab()
90092
def _schedule(self):
        ''''''
        if self._running:
            _logger.debug('')
            self._call_later_handle = self._event_loop.call_later(
                self._timeout, self._check)
853344
def is_runnnig(self):
        
        resp = None
        try:
            resp = requests.get("http://%s:%s" %(self._ip, self._port))

            if resp.status_code == 200:
                return True
            else:
                return False
        except:
            return False
169535
def start(self, interval_s):
    
    if self.running:
      return False

    self.stopped.clear()

    def _execute():
      # Always execute immediately once
      if not self.method() and self.stop_if_false:
        return
      while not self.stopped.wait(interval_s):
        if not self.method() and self.stop_if_false:
          return

    self.thread = threading.Thread(target=_execute)
    self.thread.daemon = True
    self.thread.start()
    return True
1070750
def check_due(self):
        """"""
        if self.disabled:
            return False
        if self.is_running:
            return False
        if self.delta is None:
            return False
        last_run = self.last_run
        if last_run is None:
            return True
        now = datetime.utcnow()
        if now > last_run + self.delta:
            return True
        return False
342014
public boolean schedulePolling() {
        if(isDisabled())    return false;
        SCMTrigger scmt = getTrigger(SCMTrigger.class);
        if(scmt==null)      return false;
        scmt.run();
        return true;
    }
75852
def _start_auto_refresh_thread(self):
        
        def run():
            while True:
                time.sleep(self.status_interval)
                self.invalidate()

        t = threading.Thread(target=run)
        t.daemon = True
        t.start()
1081383
def isRunning(self, waitTime=0):
        
        waitUntil = time.time() + waitTime
        while True:
            if self.getPID() > 0:
                return True
            else:
                self._pid = PlatformManager.getWindowPID(PlatformManager.getWindowByTitle(re.escape(self._title)))

            # Check if we've waited long enough
            if time.time() > waitUntil:
                break
            else:
                time.sleep(self._defaultScanRate)
        return self.getPID() > 0
358319
@Override
    public void run() {
        final ScheduledFuture<?> future = this.executor.scheduleWithFixedDelay(this.scheduled, 0, this.delayMillis,
                TimeUnit.MILLISECONDS);
        try {
            this.runTrigger.await();
        } catch (final InterruptedException e) {
            this.listener.handle(e);
        } finally {
            future.cancel(true); // stop the periodic reading
            this.scheduled.cleanup();
            this.executor.shutdownNow();
            this.listener.destroy();
        }
    }
740616
def _IsCronJobFailing(self, cron_job):
    """"""
    status = cron_job.Get(cron_job.Schema.LAST_RUN_STATUS)
    if status is None:
      return False

    return status.status != rdf_cronjobs.CronJobRunStatus.Status.OK
1074830
def run(self):
        
        self.run_plugins()
        while True:
            # Reload plugins and config if either the config file or plugin
            # directory are modified.
            if self._config_mod_time != os.path.getmtime(self._config_file_path) or \
                    self._plugin_mod_time != os.path.getmtime(self._plugin_path):
                self.thread_manager.kill_all_threads()
                self.output_dict.clear()
                self.reload()
                self.run_plugins()
            self.output_to_bar(json.dumps(self._remove_empty_output()))
            time.sleep(self.config.general['interval'])
1355452
def run(self):
        
        self.timer = t.Thread(target=self.report_spans)
        self.timer.daemon = True
        self.timer.name = "Instana Span Reporting"
        self.timer.start()
187517
def _run(self):
        

        def get_next_interval():
            start_time = time.time()
            start = 0 if self.eager else 1
            for count in itertools.count(start=start):
                yield max(start_time + count * self.interval - time.time(), 0)
        interval = get_next_interval()
        sleep_time = next(interval)
        while True:
            # sleep for `sleep_time`, unless `should_stop` fires, in which
            # case we leave the while loop and stop entirely
            with Timeout(sleep_time, exception=False):
                self.should_stop.wait()
                break

            self.handle_timer_tick()

            self.worker_complete.wait()
            self.worker_complete.reset()

            sleep_time = next(interval)