Пример #1
0
 def run(self):
     errors = 0
     while self.is_running:
         # If we fail in an Idl call, we could have missed an update
         # from the server, leaving us out of sync with ovsdb-server.
         # It is not safe to continue without restarting the connection.
         # Though it is likely that the error is unrecoverable, keep trying
         # indefinitely just in case.
         try:
             self.idl.wait(self.poller)
             self.poller.fd_wait(self.txns.alert_fileno, poller.POLLIN)
             self.poller.block()
             with self.lock:
                 self.idl.run()
         except Exception as e:
             # This shouldn't happen, but is possible if there is a bug
             # in python-ovs
             errors += 1
             LOG.exception(e)
             with self.lock:
                 self.idl.force_reconnect()
                 try:
                     idlutils.wait_for_change(self.idl, self.timeout)
                 except Exception as e:
                     # This could throw the same exception as idl.run()
                     # or Exception("timeout"), either way continue
                     LOG.exception(e)
             sleep = min(2**errors, 60)
             LOG.info("Trying to recover, sleeping %s seconds", sleep)
             time.sleep(sleep)
             continue
         errors = 0
         txn = self.txns.get_nowait()
         if txn is not None:
             try:
                 with self.lock:
                     txn.results.put(txn.do_commit())
             except Exception as ex:
                 er = idlutils.ExceptionResult(ex=ex,
                                               tb=traceback.format_exc())
                 txn.results.put(er)
             self.txns.task_done()
     self.idl.close()
Пример #2
0
 def run(self):
     while self._is_running:
         self.idl.wait(self.poller)
         self.poller.fd_wait(self.txns.alert_fileno, poller.POLLIN)
         # TODO(jlibosva): Remove next line once losing connection to ovsdb
         #                 is solved.
         self.poller.timer_wait(self.timeout * 1000)
         self.poller.block()
         self.idl.run()
         txn = self.txns.get_nowait()
         if txn is not None:
             try:
                 #记录成功执行的commands
                 txn.results.put(txn.do_commit())
             except Exception as ex:
                 er = idlutils.ExceptionResult(ex=ex,
                                               tb=traceback.format_exc())
                 txn.results.put(er)
             self.txns.task_done()
Пример #3
0
 def run(self):
     errors = 0
     while self._is_running:
         # If we fail in an Idl call, we could have missed an update
         # from the server, leaving us out of sync with ovsdb-server.
         # It is not safe to continue without restarting the connection,
         # though it is likely that the error is unrecoverable, so only try
         # a few times before bailing completely.
         try:
             self.idl.wait(self.poller)
             self.poller.fd_wait(self.txns.alert_fileno, poller.POLLIN)
             # TODO(jlibosva): Remove next line once losing connection to
             #                 ovsdb is solved.
             self.poller.timer_wait(self.timeout * 1000)
             self.poller.block()
             self.idl.run()
         except Exception as e:
             # This shouldn't happen, but is possible if there is a bug
             # in python-ovs
             errors += 1
             LOG.exception(e)
             if errors <= 3:
                 self.idl.force_reconnect()
                 idlutils.wait_for_change(self.idl, self.timeout)
                 continue
             self._is_running = False
             break
         errors = 0
         txn = self.txns.get_nowait()
         if txn is not None:
             try:
                 txn.results.put(txn.do_commit())
             except Exception as ex:
                 er = idlutils.ExceptionResult(ex=ex,
                                               tb=traceback.format_exc())
                 txn.results.put(er)
             self.txns.task_done()