예제 #1
0
 def run(self):
     while not self.cancelled.isSet():
         try:
             packed = compact()
         except:
             msglog.error("Compactor failed to run compact().")
             msglog.exception(prefix="handled")
         else:
             msglog.debug("Compacted %d DB files." % packed)
         self.cancelled.wait(self.period)
     msglog.inform("Compactor thread exiting run-loop.")
예제 #2
0
파일: _compact.py 프로젝트: mcruse/monotone
 def run(self):
     while not self.cancelled.isSet():
         try:
             packed = compact()
         except:
             msglog.error("Compactor failed to run compact().")
             msglog.exception(prefix="handled")
         else:
             msglog.debug("Compacted %d DB files." % packed)
         self.cancelled.wait(self.period)
     msglog.inform("Compactor thread exiting run-loop.")
예제 #3
0
파일: triggers.py 프로젝트: mcruse/monotone
 def start(self):
     if not self._running.isSet():
         _Trigger.start(self)
         variables = []
         self._message = ''
         message = self.message
         while '$' in message:
             index = message.index('$')
             try:
                 if message[index+1] == '{':
                     end = string.find(message,'}',index)
                     if end > -1:
                         var = message[index:end+1]
                         variable = var[2:-1]
                         if '$' not in variable and '{' not in variable:
                             message = string.replace(message,var,'%s')
                             variables.append(variable)
             except IndexError:
                 pass
             self._message += message[0:index+1]
             message = message[index+1:]
         self._message += message
         self._message_vars = tuple(variables)
         self.state = self.STATES[self.state]['start']
         self._running.set()
     try:
         Calculator.start(self)
     except:
         message = "Failed to start Trigger %r.  Will retry in 30 secs."
         msglog.error(message % self.name)
         if not self._start_failed:
             msglog.exception(prefix="handled")
         self._start_failed = True
     else:
         message = "Trigger %r started.  Evaluation runs in 30 seconds."
         msglog.inform(message % self.name)
         self._start_failed = False
     finally:
         self.reschedule(30)
예제 #4
0
 def start(self):
     if not self._running.isSet():
         _Trigger.start(self)
         variables = []
         self._message = ''
         message = self.message
         while '$' in message:
             index = message.index('$')
             try:
                 if message[index + 1] == '{':
                     end = string.find(message, '}', index)
                     if end > -1:
                         var = message[index:end + 1]
                         variable = var[2:-1]
                         if '$' not in variable and '{' not in variable:
                             message = string.replace(message, var, '%s')
                             variables.append(variable)
             except IndexError:
                 pass
             self._message += message[0:index + 1]
             message = message[index + 1:]
         self._message += message
         self._message_vars = tuple(variables)
         self.state = self.STATES[self.state]['start']
         self._running.set()
     try:
         Calculator.start(self)
     except:
         message = "Failed to start Trigger %r.  Will retry in 30 secs."
         msglog.error(message % self.name)
         if not self._start_failed:
             msglog.exception(prefix="handled")
         self._start_failed = True
     else:
         message = "Trigger %r started.  Evaluation runs in 30 seconds."
         msglog.inform(message % self.name)
         self._start_failed = False
     finally:
         self.reschedule(30)
예제 #5
0
파일: rna.py 프로젝트: mcruse/monotone
 def run(self):
     pfx = 'RNA_Scan_Thread.run:'
     cmdfd = self.trigger_channel.fileno()
     enqueue = self.work_queue.queue_noresult
     handle_session = self.handle_session_input
     clear_notifications = self.clear_notifications
     while self.bPollRun:
         try:
             descriptors = self.descriptors.copy()
             if cmdfd not in descriptors:
                 msglog.warn("Command channel FD removed!")
                 descriptors.add(cmdfd)
             r,w,e = select.select(descriptors, [], descriptors, 1)
             for fd in e:
                 if fd == cmdfd:
                     message = "%s internal polling error.  Must restart."
                     msglog.error(message % pfx)
                     raise TypeError("command channel OOB data")
                 try:
                     self.unregister_session(self.get_session(fd))
                 except:
                     msglog.warn("%s I/O event handling error." % pfx)
                     msglog.exception(prefix="handled")
             for fd in r:
                 if fd in self.descriptors:
                     try:
                         if fd == cmdfd:
                             clear_notifications()
                         else:
                             self.descriptors.discard(fd)
                             enqueue(handle_session, fd)
                     except:
                         msglog.warn("%s I/O event handling error." % pfx)
                         msglog.exception(prefix="handled")
         except:
             msglog.warn("%s loop error." % pfx)
             msglog.exception(prefix="handled")
     msglog.inform("%s exiting." % pfx)
예제 #6
0
파일: rna.py 프로젝트: ed-aicradle/monotone
 def run(self):
     pfx = 'RNA_Scan_Thread.run:'
     cmdfd = self.trigger_channel.fileno()
     enqueue = self.work_queue.queue_noresult
     handle_session = self.handle_session_input
     clear_notifications = self.clear_notifications
     while self.bPollRun:
         try:
             descriptors = self.descriptors.copy()
             if cmdfd not in descriptors:
                 msglog.warn("Command channel FD removed!")
                 descriptors.add(cmdfd)
             r, w, e = select.select(descriptors, [], descriptors, 1)
             for fd in e:
                 if fd == cmdfd:
                     message = "%s internal polling error.  Must restart."
                     msglog.error(message % pfx)
                     raise TypeError("command channel OOB data")
                 try:
                     self.unregister_session(self.get_session(fd))
                 except:
                     msglog.warn("%s I/O event handling error." % pfx)
                     msglog.exception(prefix="handled")
             for fd in r:
                 if fd in self.descriptors:
                     try:
                         if fd == cmdfd:
                             clear_notifications()
                         else:
                             self.descriptors.discard(fd)
                             enqueue(handle_session, fd)
                     except:
                         msglog.warn("%s I/O event handling error." % pfx)
                         msglog.exception(prefix="handled")
         except:
             msglog.warn("%s loop error." % pfx)
             msglog.exception(prefix="handled")
     msglog.inform("%s exiting." % pfx)