Module: properly end timer threads by tracking when module's shutdown() was called

This commit is contained in:
Brian S. Stephan 2011-04-23 12:07:30 -05:00
parent 0c5fe348dc
commit 80f2ff469c
1 changed files with 6 additions and 2 deletions

View File

@ -46,6 +46,8 @@ class Module(object):
self.config = config
self.server = server
self.is_shutdown = False
# open database connection
dbfile = self.config.get('dr.botzo', 'database')
self.conn = sqlite3.connect(dbfile)
@ -163,6 +165,8 @@ class Module(object):
will call save() before this, so implement appropriately.
"""
self.is_shutdown = True
def remove_metaoptions(self, list):
"""Remove metaoptions from provided list, which was probably from a config file."""
@ -235,10 +239,10 @@ class Module(object):
# don't actually do stuff if, since the last timer registration,
# the interval was set to 0
if self.timer_interval() > 0:
if self.timer_interval() > 0 and self.is_shutdown == False:
self.timer_do()
if self.timer_interval() > 0:
if self.timer_interval() > 0 and self.is_shutdown == False:
Timer(self.timer_interval(), self.timer_bootstrap, ()).start()
def timer_do(self):