Fix stop of loopingcall
Patch [1] for switched to use eventlet Event for loopingcall events. It may now happen that stop event is sent when other event was already sent and loopingcall is already not running. That cause AssertionError in eventlet.event module. To avoid that, we should check if if loopingcall is running before sending _abort.set(). [1] https://review.openstack.org/#/c/611807/ Closes-Bug #1800879 Change-Id: I28ad3bdb51a20350c90dee4420058c30946897e5
This commit is contained in:
parent
6694bd16be
commit
3e08f3375e
|
@ -121,6 +121,7 @@ class LoopingCallBase(object):
|
|||
return not self._abort.is_set()
|
||||
|
||||
def stop(self):
|
||||
if self._running:
|
||||
self._abort.set()
|
||||
|
||||
def wait(self):
|
||||
|
|
|
@ -100,6 +100,16 @@ class LoopingCallTestCase(test_base.BaseTestCase):
|
|||
wait_ev.set()
|
||||
timer.wait()
|
||||
|
||||
def test_no_double_stop(self):
|
||||
def _raise_it():
|
||||
raise loopingcall.LoopingCallDone(False)
|
||||
|
||||
timer = loopingcall.FixedIntervalLoopingCall(_raise_it)
|
||||
timer.start(interval=0.5)
|
||||
|
||||
timer.stop()
|
||||
timer.stop()
|
||||
|
||||
def test_repeat(self):
|
||||
self.num_runs = 2
|
||||
|
||||
|
|
Loading…
Reference in New Issue