]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix leftover Timeout effecting most eventlet calls
authorJohn Schwarz <jschwarz@redhat.com>
Thu, 4 Sep 2014 08:34:29 +0000 (11:34 +0300)
committerJohn Schwarz <jschwarz@redhat.com>
Thu, 4 Sep 2014 11:03:31 +0000 (14:03 +0300)
When registering a new eventlet.timeout.Timeout object, eventlet
automatically starts a timer for most (if not all) future eventlet
calls. Normally, eventlet codes do not hold a timeout unless such a
timeout is used or a specific timeout length is specified through
the API, but once a Timeout object is initialized, it is left there
unless canceled.

This change fixes an un-canceled Timeout which causes some
functional tests to fail, reintroduces a fix for bug #1358206,
which was written prior to discovering the uncanceled timeout, and
increases the timeout of a test that depended on this timeout.

Closes-bug: #1358206
Related-bug: #1364171
Change-Id: I1bfc5af6917c525894eecd8b477d787763edbd02

neutron/agent/linux/ovsdb_monitor.py
neutron/tests/functional/agent/linux/test_ovsdb_monitor.py

index c49bdc5f1910f0bc1f136441ec1b52b9979edabb..520865ce735b0f0893095dd5b6d686fecd82ce4f 100644 (file)
@@ -69,10 +69,6 @@ class SimpleInterfaceMonitor(OvsdbMonitor):
             respawn_interval=respawn_interval,
         )
         self.data_received = False
-        if respawn_interval:
-            self._default_timeout = respawn_interval / 2
-        else:
-            self._default_timeout = 10
 
     @property
     def is_active(self):
@@ -91,13 +87,12 @@ class SimpleInterfaceMonitor(OvsdbMonitor):
         """
         return bool(list(self.iter_stdout())) or not self.is_active
 
-    def start(self, block=False, timeout=None):
-        timeout = timeout or self._default_timeout
+    def start(self, block=False, timeout=5):
         super(SimpleInterfaceMonitor, self).start()
         if block:
-            eventlet.timeout.Timeout(timeout)
-            while not self.is_active:
-                eventlet.sleep()
+            with eventlet.timeout.Timeout(timeout):
+                while not self.is_active:
+                    eventlet.sleep()
 
     def _kill(self, *args, **kwargs):
         self.data_received = False
index 3f37ce0edc4493da3b71f81eae0413c30da2cfd5..7d6131ca97cadd31dedacb27916acf5651e3b6e6 100644 (file)
@@ -96,7 +96,7 @@ class TestSimpleInterfaceMonitor(BaseMonitorTest):
         self.monitor = ovsdb_monitor.SimpleInterfaceMonitor(
             root_helper=self.root_helper)
         self.addCleanup(self.monitor.stop)
-        self.monitor.start(block=True)
+        self.monitor.start(block=True, timeout=60)
 
     def test_has_updates(self):
         self.assertTrue(self.monitor.has_updates,