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:
Joshua Harlow 2015-09-29 15:35:40 -07:00
parent fa759a0165
commit 3ae36f6eb9

View File

@ -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.