Fix leftover Timeout effecting most eventlet calls
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
This commit is contained in:
parent
2c7d987fd4
commit
fdf0fa8b43
|
@ -69,10 +69,6 @@ class SimpleInterfaceMonitor(OvsdbMonitor):
|
||||||
respawn_interval=respawn_interval,
|
respawn_interval=respawn_interval,
|
||||||
)
|
)
|
||||||
self.data_received = False
|
self.data_received = False
|
||||||
if respawn_interval:
|
|
||||||
self._default_timeout = respawn_interval / 2
|
|
||||||
else:
|
|
||||||
self._default_timeout = 10
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
|
@ -91,13 +87,12 @@ class SimpleInterfaceMonitor(OvsdbMonitor):
|
||||||
"""
|
"""
|
||||||
return bool(list(self.iter_stdout())) or not self.is_active
|
return bool(list(self.iter_stdout())) or not self.is_active
|
||||||
|
|
||||||
def start(self, block=False, timeout=None):
|
def start(self, block=False, timeout=5):
|
||||||
timeout = timeout or self._default_timeout
|
|
||||||
super(SimpleInterfaceMonitor, self).start()
|
super(SimpleInterfaceMonitor, self).start()
|
||||||
if block:
|
if block:
|
||||||
eventlet.timeout.Timeout(timeout)
|
with eventlet.timeout.Timeout(timeout):
|
||||||
while not self.is_active:
|
while not self.is_active:
|
||||||
eventlet.sleep()
|
eventlet.sleep()
|
||||||
|
|
||||||
def _kill(self, *args, **kwargs):
|
def _kill(self, *args, **kwargs):
|
||||||
self.data_received = False
|
self.data_received = False
|
||||||
|
|
|
@ -96,7 +96,7 @@ class TestSimpleInterfaceMonitor(BaseMonitorTest):
|
||||||
self.monitor = ovsdb_monitor.SimpleInterfaceMonitor(
|
self.monitor = ovsdb_monitor.SimpleInterfaceMonitor(
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
self.addCleanup(self.monitor.stop)
|
self.addCleanup(self.monitor.stop)
|
||||||
self.monitor.start(block=True)
|
self.monitor.start(block=True, timeout=60)
|
||||||
|
|
||||||
def test_has_updates(self):
|
def test_has_updates(self):
|
||||||
self.assertTrue(self.monitor.has_updates,
|
self.assertTrue(self.monitor.has_updates,
|
||||||
|
|
Loading…
Reference in New Issue