Avoid removing entries for timers that didn't stop
It seems bad to remove timer objects for timers that didn't actually stop, so instead of removing all the timers (including the ones that had issues) only remove the ones that didn't have issues. Change-Id: I1dcb589f7f026ad8eaa9145a61c7c2c386ee438e
This commit is contained in:
parent
fa759a0165
commit
3ae36f6eb9
@ -116,12 +116,19 @@ class ThreadGroup(object):
|
||||
LOG.exception(_LE('Error stopping thread.'))
|
||||
|
||||
def stop_timers(self):
|
||||
stopped_timers = []
|
||||
for x in self.timers:
|
||||
try:
|
||||
x.stop()
|
||||
except Exception:
|
||||
LOG.exception(_LE('Error stopping timer.'))
|
||||
self.timers = []
|
||||
else:
|
||||
stopped_timers.append(x)
|
||||
for x in stopped_timers:
|
||||
try:
|
||||
self.timers.remove(x)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def stop(self, graceful=False):
|
||||
"""stop function has the option of graceful=True/False.
|
||||
|
Loading…
x
Reference in New Issue
Block a user