Example #1
0
 def run(self):
     '''
     Loop that executes scheduled tasks
     Can be executed more than once, in differents threads
     '''
     # We ensure that the jobs are also in database so we can
     logger.debug('Run Scheduler thread')
     JobsFactory.factory().ensureJobsInDatabase()
     logger.debug("At loop")
     while self._keepRunning:
         try:
             time.sleep(self.granularity)
             self.executeOneJob()
         except Exception as e:
             # This can happen often on sqlite, and this is not problem at all as we recover it.
             # The log is removed so we do not get increased workers.log file size with no information at all
             if not isinstance(e, DatabaseError):
                 logger.error(
                     'Unexpected exception at run loop {0}: {1}'.format(
                         e.__class__, e))
             try:
                 connection.close()
             except Exception:
                 logger.exception(
                     'Exception clossing connection at delayed task')
     logger.info('Exiting Scheduler because stop has been requested')
     self.releaseOwnShedules()
Example #2
0
 def run(self):
     '''
     Loop that executes scheduled tasks
     Can be executed more than once, in differents threads
     '''
     # We ensure that the jobs are also in database so we can
     logger.debug('Run Scheduler thread')
     JobsFactory.factory().ensureJobsInDatabase()
     logger.debug("At loop")
     while self._keepRunning:
         try:
             time.sleep(self.granularity)
             self.executeOneJob()
         except Exception, e:
             logger.exception('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
Example #3
0
 def run(self):
     '''
     Loop that executes scheduled tasks
     Can be executed more than once, in differents threads
     '''
     # We ensure that the jobs are also in database so we can
     logger.debug('Run Scheduler thread')
     JobsFactory.factory().ensureJobsInDatabase()
     logger.debug("At loop")
     while self._keepRunning:
         try:
             time.sleep(self.granularity)
             self.executeOneJob()
         except Exception, e:
             logger.exception(
                 'Unexpected exception at run loop {0}: {1}'.format(
                     e.__class__, e))
Example #4
0
 def getInstance(self):
     '''
     Returns an instance of the class that this record of the Scheduler represents. This clas is derived
     of uds.core.jobs.Job.Job
     '''
     jobInstance = JobsFactory.factory().lookup(self.name)
     if jobInstance != None:
         env = self.getEnvironment()
         return jobInstance(env)
     else:
         return None
Example #5
0
 def run(self):
     '''
     Loop that executes scheduled tasks
     Can be executed more than once, in differents threads
     '''
     # We ensure that the jobs are also in database so we can
     logger.debug('Run Scheduler thread')
     JobsFactory.factory().ensureJobsInDatabase()
     logger.debug("At loop")
     while self._keepRunning:
         try:
             time.sleep(self.granularity)
             self.executeOneJob()
         except Exception as e:
             logger.error('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
             try:
                 connection.close()
             except Exception:
                 logger.exception('Exception clossing connection at delayed task')
     logger.info('Exiting Scheduler because stop has been requested')
     self.releaseOwnShedules()
Example #6
0
 def run(self):
     """
     Loop that executes scheduled tasks
     Can be executed more than once, in differents threads
     """
     # We ensure that the jobs are also in database so we can
     logger.debug('Run Scheduler thread')
     JobsFactory.factory().ensureJobsInDatabase()
     logger.debug("At loop")
     while self._keepRunning:
         try:
             time.sleep(self.granularity)
             self.executeOneJob()
         except Exception as e:
             # This can happen often on sqlite, and this is not problem at all as we recover it.
             # The log is removed so we do not get increased workers.log file size with no information at all
             if not isinstance(e, DatabaseError):
                 logger.error('Unexpected exception at run loop {0}: {1}'.format(e.__class__, e))
             try:
                 connection.close()
             except Exception:
                 logger.exception('Exception clossing connection at delayed task')
     logger.info('Exiting Scheduler because stop has been requested')
     self.releaseOwnShedules()
Example #7
0
def factory():
    '''
    Returns a singleton to a jobs factory
    '''
    from uds.core.jobs.JobsFactory import JobsFactory
    return JobsFactory.factory()
Example #8
0
def factory():
    """
    Returns a singleton to a jobs factory
    """
    from uds.core.jobs.JobsFactory import JobsFactory
    return JobsFactory.factory()
Example #9
0
def factory():
    """
    Returns a singleton to a jobs factory
    """
    from uds.core.jobs.JobsFactory import JobsFactory
    return JobsFactory.factory()