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
13709b17eb
commit
02ee2f3962
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user