Exemple #1
0
    def tick(self):
        """Run a tick, that is one iteration of the scheduler.
        Executes all due tasks.
        """
        # need to grab all data (might have been updated) from schedule DB.
        # we need to merge it with whatever schedule was set in config, and
        # already installed default tasks
        try:
            s = self.all_as_schedule()
            self.merge_inplace(s)
        except Exception as exc:
            logger.error(
                "Exception when getting tasks from {url} : {exc}".format(
                    url=self.schedule_url, exc=exc))
            # TODO : atomic merge : be able to cancel it if there s a problem
            raise

        # displaying the schedule we got from redis
        logger.debug("DB schedule : {0}".format(self.schedule))

        if celery.__version__ > "4":
            if self.heap_to_none or not self._heap:
                self.logger.debug("set heap to none")
                self._heap = None
                self.heap_to_none = False

        # this will call self.maybe_due() to check if any entry is due.
        return super(RedisScheduler, self).tick()
Exemple #2
0
 def check_connection(self):
     try:
         self.cursor.execute("SELECT VERSION()")
         results = self.cursor.fetchone()
         # Check if anything at all is returned
         if results:
             return True
         else:
             logger.error("Error to execute query")
             self.__init__()
             return False
     except MySQLdb.Error:
         logger.error("Error in connection")
         self.__init__()
     return False
Exemple #3
0
 def sync(self):
     if not self.save_entry_back:
         logger.info('Without save entry back to redis...')
         return
     logger.info('Writing modified entries...')
     _tried = set()
     try:
         while self._dirty:
             name = self._dirty.pop()
             _tried.add(name)
             # Saving the entry back into Redis DB.
             try:
                 self.rdb.set(name, self.schedule[name].jsondump())
             except KeyError:
                 logger.warning("rdb key %s may be already removed." % name)
     except Exception as exc:
         # retry later
         self._dirty |= _tried
         logger.error('Error while sync: %r', exc, exc_info=1)
Exemple #4
0
 def die(self, msg):
     logger.error("*** ERROR *** " + msg)
     self._errmsg = msg
     self._errors = True
     self.exit()
Exemple #5
0
 def die(self, msg):
   logger.error("*** ERROR *** " + msg)
   self._errmsg = msg
   self._errors = True
   self.exit()
def invalid(workout_id):
    page_template = 'invalid_workout.html'
    logger.error(f'/invalid/{workout_id}')
    return render_template(page_template)