From 46e4323bed91b6b5eb2779ec62754d9486237590 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Wed, 7 Nov 2018 16:01:42 -0600 Subject: [PATCH] Expand retry behavior to cover other python-ovs methods If there is a disconnect, it is possible that we could throw an exception if we call wait() while the stream is currently set to None. Move the try: earlier so that if something weird happens, we at least retry before raising. Change-Id: Ic820ab3978a3b58a41762e6fca034f62d51a0243 --- ovsdbapp/backend/ovs_idl/connection.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ovsdbapp/backend/ovs_idl/connection.py b/ovsdbapp/backend/ovs_idl/connection.py index d1c3621f..347f95c9 100644 --- a/ovsdbapp/backend/ovs_idl/connection.py +++ b/ovsdbapp/backend/ovs_idl/connection.py @@ -91,18 +91,18 @@ class Connection(object): def run(self): errors = 0 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() - # If we fail on a run() call, we could have missed an update + # 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