Exemple #1
0
    def start(self):
        # Gracefully exit all threads on SIG_INT or SIG_TERM
        threadpool.catch_signals()

        # Start threads
        self.Loggers.start()
        self.Delinkers.start()
        self.CheckUsages.start()

        # Give threads some time to initialize
        time.sleep(self.config['timeout'])
        output(u'All workers started')

        # Main loop
        while True:
            if self.config.get('enable_delinker', True):
                if 'deletion_log_table' in self.config:
                    if not self.read_deletion_log_db():
                        self.read_deletion_log()
                else:
                    self.read_deletion_log()
            if self.config.get('enable_replacer', False):
                self.read_replacement_log()

            time.sleep(self.config['timeout'])
Exemple #2
0
 def start(self):
     # Gracefully exit all threads on SIG_INT or SIG_TERM
     threadpool.catch_signals()
     
     # Start threads
     self.Loggers.start()
     self.Delinkers.start()
     self.CheckUsages.start()
     
     # Give threads some time to initialize
     time.sleep(self.config['timeout'])
     output(u'All workers started')
     
     # Main loop
     while True:
         if self.config.get('enable_delinker', True):
             if 'deletion_log_table' in self.config:
                 if not self.read_deletion_log_db():
                     self.read_deletion_log()
             else:
                 self.read_deletion_log()
         if self.config.get('enable_replacer', False):
             self.read_replacement_log()
             
         time.sleep(self.config['timeout'])
Exemple #3
0
    def start(self):
        start_time = time.time()

        # Gracefully exit all threads on SIG_INT or SIG_TERM
        threadpool.catch_signals()

        # Start threads
        self.Loggers.start()
        self.Delinkers.start()
        self.CheckUsages.start()

        # Give threads some time to initialize
        time.sleep(self.config['timeout'])
        output(u'All workers started')

        # Main loop
        while True:
            if self.config.get('enable_delinker', True):
                if 'deletion_log_table' in self.config:
                    if not self.read_deletion_log_db():
                        self.read_deletion_log()
                else:
                    self.read_deletion_log()
            if self.config.get('enable_replacer', False):
                self.read_replacement_log()

            if 'max_runtime' in self.config:
                if (self.config['max_runtime'] + start_time) < time.time():
                    output(u'Maximum run time exceeded; trying to shutdown')
                    while not (self.CheckUsages.is_idle()
                               and self.Delinkers.is_idle()
                               and self.Loggers.is_idle()):
                        time.sleep(self.config['timeout'])

                    self.CheckUsages.exit()
                    self.Delinkers.exit()
                    self.Loggers.exit()
                    output(u'All work done; exiting')
                    break

            time.sleep(self.config['timeout'])

        # Store the last time the deletion log was checked
        if 'deletion_log_store' in self.config:
            open(self.config['deletion_log_store'],
                 'w').write(str(self.last_check))
            output(u'Storing session end at %i' % self.last_check)
    def start(self):
        start_time = time.time()
        
        # Gracefully exit all threads on SIG_INT or SIG_TERM
        threadpool.catch_signals()

        # Start threads
        self.Loggers.start()
        self.Delinkers.start()
        self.CheckUsages.start()

        # Give threads some time to initialize
        time.sleep(self.config['timeout'])
        output(u'All workers started')

        # Main loop
        while True:
            if self.config.get('enable_delinker', True):
                if 'deletion_log_table' in self.config:
                    if not self.read_deletion_log_db():
                        self.read_deletion_log()
                else:
                    self.read_deletion_log()
            if self.config.get('enable_replacer', False):
                self.read_replacement_log()
            
            if 'max_runtime' in self.config:
                if (self.config['max_runtime'] + start_time) < time.time():
                    output(u'Maximum run time exceeded; trying to shutdown')
                    while not (self.CheckUsages.is_idle() and
                               self.Delinkers.is_idle() and
                               self.Loggers.is_idle()):
                        time.sleep(self.config['timeout'])
                    
                    self.CheckUsages.exit()
                    self.Delinkers.exit()
                    self.Loggers.exit()
                    output(u'All work done; exiting')
                    break
                    
            time.sleep(self.config['timeout'])
            
        # Store the last time the deletion log was checked
        if 'deletion_log_store' in self.config:
            open(self.config['deletion_log_store'], 'w').write(str(self.last_check))
            output(u'Storing session end at %i' % self.last_check)