Merge "Avoid removing entries for timers that didn't stop"

This commit is contained in:
Jenkins 2015-11-11 13:50:18 +00:00 committed by Gerrit Code Review
commit 8b2f286e04

View File

@ -120,12 +120,19 @@ class ThreadGroup(object):
lambda x: 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.