def main_loop(self):
        self.journal = Journal(self.impact_limits,
                               logger_instance=self.logger_instance)
        if self.scheduler_plugin is None:
            self.logger_instance.logit("Error",
                                       "Scheduler NOT found")
            sys.exit(0)
        self.logger_instance.logit("INFO",
                                   "As defined in destiny, using"
                                   " the scheduler plugin: {0}"
                                   .format(self.scheduler_plugin),
                                   log_level="VERBOSE")
        try:
            scheduler_module = __import__(SCHEDULER_PLUGIN_PATH + '.' +
                                          self.scheduler_plugin + '.' +
                                          self.scheduler_plugin,
                                          fromlist=self.scheduler_plugin)
        except ImportError:
            self.logger_instance.logit("Error",
                                       "The scheduler plugin {0}"
                                       " not found"
                                       .format(self.scheduler_plugin),
                                       log_level="VERBOSE")
            raise
        try:
            scheduler_class = getattr(scheduler_module, self.scheduler_plugin)
            scheduler = scheduler_class(self.get_scheduler_destiny(),
                                        verbose=True)
        except (AttributeError, KeyError):
            self.logger_instance.logit("Error",
                                       "The scheduler class {0}"
                                       " not found"
                                       .format(self.scheduler_plugin),
                                       log_level="VERBOSE")
            raise

        # Put all the atropos specific info into the output queue
        self.output_queue.put((self.service, self.get_all_nodes(),
                               scheduler.get_plan()))

        for event in scheduler.get_plan():
            for failure_name, trigger_time in event.iteritems():
                self.logger_instance.logit("INFO", "Acting on NonDeterministic"
                                                   " plan: {0}, triggertime:"
                                                   " {1}, service name: {2}".
                                           format(failure_name,
                                                  datetime.datetime.
                                                  fromtimestamp(
                                                      int(trigger_time)),
                                                  self.service),
                                           log_level="VERBOSE")
                current_timestamp = int(time.time())
                if current_timestamp > trigger_time:
                    self.logger_instance.logit("WARNING",
                                               "Encountered a missed event"
                                               " in the plan. Skipping: {0}"
                                               .format(failure_name))
                    # Add an item in event queue specifying that
                    self.event_queue.put((self.service, failure_name,
                                          trigger_time, "NOT_DECIDED", False))
                    self.event_queue.put((self.service, failure_name +
                                          "-revert", trigger_time,
                                          "NOT_DECIDED", False))
                    continue
                else:
                    self.logger_instance.logit("INFO",
                                               "Sleeping till {0} to induce:"
                                               " {1} on random node"
                                               .format(
                                                   datetime.datetime.
                                                   fromtimestamp(
                                                       int(trigger_time)),
                                                   failure_name))
                    sleep_correctly(trigger_time - current_timestamp)
                    random_node = self.get_random_node()
                    if not random_node:
                        self.logger_instance.logit("FATAL",
                                                   "Could not "
                                                   "get_random_node()."
                                                   " Skipping this cycle.")
                        self.event_queue.put((self.service, failure_name,
                                              trigger_time, "FAILED_TO_FETCH",
                                              False))
                        self.event_queue.put((self.service, failure_name +
                                              "-revert", trigger_time,
                                              "FAILED_TO_FETCH", False))

                        continue
                    self.logger_instance.logit("INFO",
                                               "Waking up to induce: {0}"
                                               " on the node: {1}".
                                               format(failure_name,
                                                      random_node))
                    self.execute_fate(random_node, failure_name, trigger_time)
        if self.verbose:
            print '[VERBOSE INFO]:', self.service, 'main_loop completed'
Atropos receives the plan from the scheduler and follows
dataset/ETHPy150Open linkedin/simoorg/src/simoorg/atropos.py/Atropos.main_loop